durusmail: durus-users: PersistentList.data_is
PersistentList.data_is
2007-11-05
2007-11-05
2007-11-05
2007-11-05
2007-11-05
2007-11-05
2007-11-05
PersistentList.data_is
Patrick K. O'Brien
2007-11-05
On Nov 5, 2007, at 6:30 AM, Andrew Bettison wrote:

> Shouldn't that last line be:
>
>     ...         self.data = self.data_is(*args, **kwargs)
>
> Other places where data_is should perhaps be used are __setslice__,
> __add__, __radd__ and __iadd__.
>
> The same question goes for PersistentDict.data_is and
> PersistentSet.s_is.
>
> I ask because I want to use PersistentList to wrap my own subclass of
> builtin list (Python 2.4+), and it would seem the best way to do it
> would be:
>
>>>> class MyPersistentList(PersistentList):
>     ...     data_is = MyList
>
> But at the moment that would not work.

While I agree with you in principle, I would be concerned about the
performance impact of this change (having to reference self).  I've
got some very big Durus databases that need to be as fast as
possible.  So if this change would have a negative impact on that, I
would suggest overriding in your subclass those handful of methods
that you mentioned.  Fortunately, it wouldn't be very much code on
your end.  Even if it is less elegant than your suggestion.

Just my opinion.  Sometimes speed is a higher priority than code
elegance and flexibility...  :-)

Here is another thought.  Durus could have a base class
(PersistentListBase) coded as you described, that you could subclass,
and the Durus PersistentList could inherit from PersistentListBase
and override certain methods with the current code which is optimized
for speed.  That would give you the best of both worlds, but would be
more work for the Durus folks.

Of course, all of this is without knowing the actual performance
characteristics of the proposed change...

Pat

--
Patrick K. O'Brien
Orbtech    http://www.orbtech.com
Schevo     http://www.schevo.org


reply