Enabled __slots__ on RingBuffer.

This commit is contained in:
Jeremy Fincher 2003-04-22 11:02:39 +00:00
parent 45b4d95184
commit 25daf96a9c
1 changed files with 10 additions and 1 deletions

View File

@ -42,7 +42,7 @@ import types
__all__ = ['RingBuffer', 'queue', 'MaxLengthQueue']
class RingBuffer(object):
#__slots__ = ('L', 'i', 'full')
__slots__ = ('L', 'i', 'full', 'maxSize')
def __init__(self, maxSize, seq=()):
if maxSize <= 0:
raise ValueError, 'maxSize must be > 0.'
@ -145,6 +145,15 @@ class RingBuffer(object):
else:
return 'RingBuffer(%r, %r)' % (self.maxSize, list(self))
def __getstate__(self):
return (self.maxSize, self.full, self.i, self.L)
def __setstate__(self, (maxSize, full, i, L)):
self.maxSize = maxSize
self.full = full
self.i = i
self.L = L
class queue(object):
__slots__ = ('front', 'back')