Add a suggestion to make more callables picklable (as multiprocessing

already does)
This commit is contained in:
Antoine Pitrou 2011-08-16 12:12:02 +02:00
parent f484655b83
commit 605d5638fe
1 changed files with 14 additions and 3 deletions

View File

@ -67,12 +67,20 @@ Currently, classes whose __new__ mandates the use of keyword-only arguments
can not be pickled (or, rather, unpickled) [3]_. Both a new special method
(``__getnewargs_ex__`` ?) and a new opcode (NEWOBJEX ?) are needed.
Serializing more callable objects
---------------------------------
Currently, only module-global functions are serializable. Multiprocessing
has custom support for pickling other callables such as bound methods [4]_.
This support could be folded in the protocol, and made more efficient
through a new GETATTR opcode.
Serializing "pseudo-global" objects
-----------------------------------
Objects which are not module-global, but should be treated in a similar
fashion -- such as methods [4]_ or nested classes -- cannot currently be
pickled (or, rather, unpickled) because the pickle protocol does not
fashion -- such as unbound methods [5]_ or nested classes -- cannot currently
be pickled (or, rather, unpickled) because the pickle protocol does not
correctly specify how to retrieve them. One solution would be through the
adjunction of a ``__namespace__`` (or ``__qualname__``) to all class and
function objects, specifying the full "path" by which they can be retrieved.
@ -119,7 +127,10 @@ References
.. [3] "pickle/copyreg doesn't support keyword only arguments in __new__":
http://bugs.python.org/issue4727
.. [4] "pickle should support methods":
.. [4] Lib/multiprocessing/forking.py:
http://hg.python.org/cpython/file/baea9f5f973c/Lib/multiprocessing/forking.py#l54
.. [5] "pickle should support methods":
http://bugs.python.org/issue9276
Copyright