@@ -384,7 +384,8 @@ The following types can be pickled:
384384
385385* tuples, lists, sets, and dictionaries containing only picklable objects
386386
387- * functions defined at the top level of a module
387+ * functions defined at the top level of a module (using :keyword: `def `, not
388+ :keyword: `lambda `)
388389
389390* built-in functions defined at the top level of a module
390391
@@ -402,7 +403,7 @@ raised in this case. You can carefully raise this limit with
402403:func: `sys.setrecursionlimit `.
403404
404405Note that functions (built-in and user-defined) are pickled by "fully qualified"
405- name reference, not by value. This means that only the function name is
406+ name reference, not by value. [ # ]_ This means that only the function name is
406407pickled, along with the name of the module the function is defined in. Neither
407408the function's code, nor any of its function attributes are pickled. Thus the
408409defining module must be importable in the unpickling environment, and the module
@@ -850,6 +851,9 @@ The following example reads the resulting pickled data. ::
850851
851852.. [# ] Don't confuse this with the :mod: `marshal ` module
852853
854+ .. [# ] This is why :keyword: `lambda ` functions cannot be pickled: all
855+ :keyword: `lambda ` functions share the same name: ``<lambda> ``.
856+
853857 .. [# ] The exception raised will likely be an :exc: `ImportError ` or an
854858 :exc: `AttributeError ` but it could be something else.
855859
0 commit comments