slice object unpickable
exarkun at divmod.com
exarkun at divmod.com
Tue Nov 2 12:20:04 EST 2004
On Tue, 02 Nov 2004 08:50:45 -0800, Josiah Carlson <jcarlson at uci.edu> wrote:
>
> sdementen at hotmail.com (Sebastien de Menten) wrote:
> >
> > Hi,
> >
> > I wonder why the slice object is not pickable via pickle or cPickle.
> > E.g.:
>
> [snip slice pickling]
>
> I don't know why clice pickling was disabled.
>
> To get past it, why not just store the argument tuples that lead to
> slices? (sli.start, sli.stop, sli.step)
>
Or use the copy_reg module to make them pickleable:
def pickleSlice(slice):
return unpickleSlice, (slice.start, slice.stop, slice.step)
def unpickleSlice(start, stop, step):
return slice(start, stop, step)
copy_reg.pickle(slice, pickleSlice, unpickleSlice)
Jp
More information about the Python-list
mailing list