[Python-checkins] cpython: Issue #19272: slight clarification of pickle docs with regard to lambda.

ethan.furman python-checkins at python.org
Fri Oct 18 09:45:53 CEST 2013


http://hg.python.org/cpython/rev/d103ba56710e
changeset:   86420:d103ba56710e
user:        Ethan Furman <ethan at stoneleaf.us>
date:        Fri Oct 18 00:45:40 2013 -0700
summary:
  Issue #19272: slight clarification of pickle docs with regard to lambda.

files:
  Doc/library/pickle.rst |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -384,7 +384,8 @@
 
 * tuples, lists, sets, and dictionaries containing only picklable objects
 
-* functions defined at the top level of a module
+* functions defined at the top level of a module (using :keyword:`def`, not
+  :keyword:`lambda`)
 
 * built-in functions defined at the top level of a module
 
@@ -402,7 +403,7 @@
 :func:`sys.setrecursionlimit`.
 
 Note that functions (built-in and user-defined) are pickled by "fully qualified"
-name reference, not by value.  This means that only the function name is
+name reference, not by value. [#]_  This means that only the function name is
 pickled, along with the name of the module the function is defined in.  Neither
 the function's code, nor any of its function attributes are pickled.  Thus the
 defining module must be importable in the unpickling environment, and the module
@@ -850,6 +851,9 @@
 
 .. [#] Don't confuse this with the :mod:`marshal` module
 
+.. [#] This is why :keyword:`lambda` functions cannot be pickled:  all
+    :keyword:`lambda` functions share the same name:  ``<lambda>``.
+
 .. [#] The exception raised will likely be an :exc:`ImportError` or an
    :exc:`AttributeError` but it could be something else.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list