summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-01-28 03:17:21 (GMT)
committerGuido van Rossum <guido@python.org>2003-01-28 03:17:21 (GMT)
commite0b904232fc93a818aae0740cfb7b076a513a5da (patch)
tree321ecd182495f9a3cc2360a5c0b9e6ca3d87b66d
parent5c938d00a1cbe5b7d0c478987b726bb31f169c82 (diff)
downloadcpython-e0b904232fc93a818aae0740cfb7b076a513a5da.zip
cpython-e0b904232fc93a818aae0740cfb7b076a513a5da.tar.gz
cpython-e0b904232fc93a818aae0740cfb7b076a513a5da.tar.bz2
Add a comment explaining that struct.pack() beats marshal.dumps(), but
marshal.loads() beats struct.unpack()! Possibly because the latter creates a one-tuple. :-(
-rw-r--r--Lib/pickle.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index b812e67..cb27f8a 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -45,6 +45,9 @@ compatible_formats = ["1.0", # Original protocol 0
"2.0", # Protocol 2
] # Old format versions we can read
+# Why use struct.pack() for pickling but marshal.loads() for
+# unpickling? struct.pack() is 40% faster than marshal.loads(), but
+# marshal.loads() is twice as fast as struct.unpack()!
mloads = marshal.loads
class PickleError(Exception):