]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
memoize(): Reworded the docs to try to disentangle the Pickler's memo
authorTim Peters <tim.peters@gmail.com>
Mon, 27 Jan 2003 21:22:10 +0000 (21:22 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 27 Jan 2003 21:22:10 +0000 (21:22 +0000)
dict from the Unpickler's memo (which is a different beast!).

Lib/pickle.py

index 1fc1a65759f645a7e7b84b48c38dc8194cc4c80f..4d7a5bec2b01b23df3f1f40192bd535a8f38bed7 100644 (file)
@@ -175,14 +175,18 @@ class Pickler:
     def memoize(self, obj):
         """Store an object in the memo."""
 
-        # The memo is a dictionary mapping object ids to 2-tuples
-        # that contains the memo value and the object being memoized.
-        # The memo value is written to the pickle and will become
+        # The Pickler memo is a dictionary mapping object ids to 2-tuples
+        # that contain the Unpickler memo key and the object being memoized.
+        # The memo key is written to the pickle and will become
         # the key in the Unpickler's memo.  The object is stored in the
-        # memo so that transient objects are kept alive during pickling.
-
-        # The use of the memo length as the memo value is just a convention.
-        # The only requirement is that the memo values by unique.
+        # Pickler memo so that transient objects are kept alive during
+        # pickling.
+
+        # The use of the Unpickler memo length as the memo key is just a
+        # convention.  The only requirement is that the memo values be unique.
+        # But there appears no advantage to any other scheme, and this
+        # scheme allows the Unpickler memo to implemented as a plain (but
+        # growable) array, indexed by memo key.
         d = id(obj)
         memo_len = len(self.memo)
         self.write(self.put(memo_len))