[issue19272] Can't pickle lambda (while named functions are ok)
Ethan Furman
report at bugs.python.org
Wed Oct 16 19:50:45 CEST 2013
Ethan Furman added the comment:
According to the docs[1]:
12.1.4. What can be pickled and unpickled?
The following types can be pickled:
- None, True, and False
- integers, floating point numbers, complex numbers
- strings, bytes, bytearrays
- tuples, lists, sets, and dictionaries containing only picklable objects
- functions defined at the top level of a module
- built-in functions defined at the top level of a module
- classes that are defined at the top level of a module
- instances of such classes whose __dict__ or the result of calling
__getstate__() is picklable
Notice that lambda is not in that list.
The docs for concurrent.futures.ProcessPoolExecutor[2] state:
17.4.3. ProcessPoolExecutor
The ProcessPoolExecutor class is an Executor subclass that uses a pool of processes to execute calls asynchronously. ProcessPoolExecutor uses the multiprocessing module, which allows it to side-step the Global Interpreter Lock but also means that only picklable objects can be executed and returned.
[1] http://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
[2] http://docs.python.org/dev/libraryconcurrent.futures.html?highlight=concurrent#processpoolexecutor
----------
nosy: +ethan.furman
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19272>
_______________________________________
More information about the Python-bugs-list
mailing list