Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

## page was renamed from enhancements/picking The current mechanism of having to define __reduce__ for every cdef class is cumbersome and hard to understand. Superclass relations are not inherently respected. In addition, requiring the first argument to be a python function litters the code with simple one-line functions just to re-create objects.

The vast majority of this could be automated--pickle all the members (and possibly the __dict__) and then restore on unpickling. For python types the pickling would be handled recursively. For non-python types, some could be handled automatically (e.g. the basic c datatypes, structs recursively) wheras others would require more specification.

Perhaps there could be a way of specifying a function to serialize a declared type. (E.g. if one does ctypedef foo, then one could specify two functions int serialize_foo(void* data, foo x)}} and {{{bint unserialize_foo(void * data, foo* x, int length) and all pickling of foo slots would be handled automatically.

Something as simple as an int* still poses a problem, however, as the length not implicit. Perhaps one would define a special method to pickle such slots? One per slot (which would be concatenated in C)?

PEX autogenerates a __reduce__, we should look at how they do that.

Something went wrong with that request. Please try again.