Commit 73d0d7a0 authored by Robert Bradshaw's avatar Robert Bradshaw

Pickling docs.

parent 2c47e7d3
...@@ -22,6 +22,8 @@ Features added ...@@ -22,6 +22,8 @@ Features added
* ``abs()`` is optimised for C complex numbers. * ``abs()`` is optimised for C complex numbers.
Patch by da-woods (Github issue #1648). Patch by da-woods (Github issue #1648).
* cdef classes now support pickling by default when possible.
Bugs fixed Bugs fixed
---------- ----------
......
...@@ -550,6 +550,23 @@ If you can be sure addresses will contain only references to strings, ...@@ -550,6 +550,23 @@ If you can be sure addresses will contain only references to strings,
the above would be safe, and it may yield a significant speedup, depending on the above would be safe, and it may yield a significant speedup, depending on
your usage pattern. your usage pattern.
Controlling pickling
====================
By default, Python will generate a ``__reduce__`` to allow pickling an extension
type if and only if each of its members are convertible to Python and it has
no ``__cinit__`` method.
To require this behavior (i.e. throw an error at compile time if a class
cannot be pickled) decorate the class with ``@cython.auto_pickle(True)``.
One can also annotate with ``@cython.auto_pickle(False)`` to get the old
behavior of not generating a ``__reduce__`` method in any case.
Manually implementing a ``__reduce__`` or `__reduce_ex__`` method will also
disable this auto-generation and can be used to support pickling of more
complicated types.
Public and external extension types Public and external extension types
==================================== ====================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment