mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
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:
parent
5c938d00a1
commit
e0b904232f
1 changed files with 3 additions and 0 deletions
|
|
@ -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):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue