[Cython] Cython creates non-pickleable classes
Serhiy Storchaka
storchaka at gmail.com
Mon Jan 11 15:32:44 EST 2016
Sorry, I'm not very familiar with Cython, but it looks to me that Cython
creates extension classes that can't be correctly copied and unpickled.
Since default __reduce_ex__ implementation knows nothing about Cython
class structure, it's result doesn't contain the state of the object.
The object could be pickled, but unpickled object doesn't contain
original values of fields, it is just non-initialized. In recent CPython
releases was added new restrictions for pickling objects that can't be
correctly unpickled. This had added incompatibility with Cython classes.
Building some packages now is failed, because Cython makes a deep copy
that actually doesn't work.
See for original changes and discussion about the regression:
http://bugs.python.org/issue22995 .
Besides the fact of Cython regression, it looks to me, that Cython also
needs to be fixed. It can be done either by generating default
pickle-related methods (__getnewargs__/__getnewargs_ex__, or
__getstate__ + __setstate__, or __reduce__/__reduce_ex__) for all Cython
classes, or implementing pickling or deepcopying only for NameAssignment
and like.
More information about the cython-devel
mailing list