I am working on a project built on python 2.4 (It is an embedded python project, so I don't have a choice on the version of python used). Throughout the application, we use array.array
to store data.
Support for pickling array.array
objects was added to pickle
(and cPickle
) in 2.5. We have a viable workaround in 2.4 when using the pure python pickle class (we subclass Pickler/Unpickler to handle arrays) but this does not work with cPickle (we need this due to performance problems).
Any suggestions?
You can use the standard library module copy_reg to register functions to deal with pickling instances of types that don't natively support pickling; cPickle
will use your registered functions where needed. I'd apply exactly this "hook" approach to your requirement of pickling instances of array.array
.