[Cython] Auto-pickle progress?
Sturla Molden
sturla at molden.no
Tue Sep 25 12:44:04 CEST 2012
On 20.09.2012 21:11, Ian Bell wrote:
> Auto-pickling would be tremendously helpful as pickling and unpickling
> is one of the most annoying features of working with threads and
> processes in python.
How should Cython interfere how to pickle a C pointer?
cdef class foobar:
cdef double *data
A C object can be anything. Cython does not know anything about size,
offset or strides, or even if it's safe to take a copy.
Example: How to pickle a shared memory buffer? Surely we cannot take a
copy, because that would defeat the purpose of "shared" memory. And even
if could take a copy, how many bytes should be copied? Do you think an
autopickler could have figured this out?
https://github.com/sturlamolden/sharedmem-numpy/blob/master/sharedmem/sharedmemory_sysv.pyx
https://github.com/sturlamolden/sharedmem-numpy/blob/master/sharedmem/sharedmemory_win.pyx
On yes, the code is different on Unix and Windows, something the
auto-pickler could not possibly know either.
Auto-pickling cdef classes is not doable, IMHO.
And by the way, implementing a __reduce__ method manually is not very
difficult either.
Sturla Molden
More information about the cython-devel
mailing list