Add a comment explaining that struct.pack() beats marshal.dumps(), but

marshal.loads() beats struct.unpack()!  Possibly because the latter
creates a one-tuple. :-(
This commit is contained in:
Guido van Rossum 2003-01-28 03:17:21 +00:00
parent 5c938d00a1
commit e0b904232f

View file

@ -45,6 +45,9 @@ compatible_formats = ["1.0", # Original protocol 0
"2.0", # Protocol 2 "2.0", # Protocol 2
] # Old format versions we can read ] # 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 mloads = marshal.loads
class PickleError(Exception): class PickleError(Exception):