Looking for a list subclassing example...
dgallion1 at yahoo.com
Wed Jun 5 02:35:32 CEST 2002
I don't use this code now but I checked and it had a memory leak.
Which the "del self[:-self.limit]" fixed.
I didn't need support for slices. Guess I should have coded an assert
into those other methods.
Jeff Epler wrote:
> I don't think the line
>> self = self[-self.limit:]
> can do what you want (it only changes something about the locals in
> the method). You almost certainly need to use slice deletion
> del self[:-self.limit]
> if diff > 0: del self[:diff]
> (these seem to work in all cases, even when diff == 1). You also haven't
> overridden the slice assignment method, extend(), __add__, or __mult__
> to make sure the length invariant is preserved in cases like
> x[:0] = ['ha ha'] * 1000
> x = x + ['ha ha'] * 1000
> x = x * 1000
More information about the Python-list