slice object unpickable
Sebastien de Menten
sdementen at hotmail.com
Tue Nov 2 11:29:15 CET 2004
I wonder why the slice object is not pickable via pickle or cPickle.
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/pickle.py", line 1386, in dumps
Pickler(file, protocol, bin).dump(obj)
File "/usr/lib/python2.3/pickle.py", line 231, in dump
File "/usr/lib/python2.3/pickle.py", line 313, in save
rv = reduce(self.proto)
File "/usr/lib/python2.3/copy_reg.py", line 69, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle slice objects
Is it an omission ? Am I missing something non trivial that would
impede slices to be pickable ?
My main goal is to pickle an object with some slices as attributes. As
my object is quite simple, I would like to enjoy the automatic pickle
system (i.e. not rewrite a __getstate__, __setstate__, etc).
Is there an easy workaround to the "unpickableness" of slices ? I
tried subclassing slices but it is not allowed.
Thanks for your help.
More information about the Python-list