summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-27 21:22:10 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-27 21:22:10 (GMT)
commite46b73f5b3822af74d994a1bbfc13843d93c90eb (patch)
tree1e71d9b5cbf3913a4845d0a9c024d163fb95ba54 /Lib
parentbbf63cd05c9bc24964daeee7e5799d0f21091ad3 (diff)
downloadcpython-e46b73f5b3822af74d994a1bbfc13843d93c90eb.zip
cpython-e46b73f5b3822af74d994a1bbfc13843d93c90eb.tar.gz
cpython-e46b73f5b3822af74d994a1bbfc13843d93c90eb.tar.bz2
memoize(): Reworded the docs to try to disentangle the Pickler's memo
dict from the Unpickler's memo (which is a different beast!).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pickle.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 1fc1a65..4d7a5be 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -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))