]> granicus.if.org Git - python/commitdiff
Add a comment explaining that struct.pack() beats marshal.dumps(), but
authorGuido van Rossum <guido@python.org>
Tue, 28 Jan 2003 03:17:21 +0000 (03:17 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 28 Jan 2003 03:17:21 +0000 (03:17 +0000)
marshal.loads() beats struct.unpack()!  Possibly because the latter
creates a one-tuple. :-(

Lib/pickle.py

index b812e675c5aaa2fe47a9c2e196416b5fbe35836e..cb27f8ab859af94db868c98eb99a2576f2e2d085 100644 (file)
@@ -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):