summaryrefslogtreecommitdiff
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-09 18:33:21 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-09 18:33:21 +0000
commit2327df02dbb845329d794294d0a71590f721f619 (patch)
tree99a71cd495ba595f60562bd26027231b9a9a7bdd /Lib/pickle.py
parent400e761b9b38c7ed0b445c23ce053ea822bf7f7d (diff)
downloadcpython-2327df02dbb845329d794294d0a71590f721f619.tar.gz
Issue #9410: Various optimizations to the pickle module, leading to
speedups up to 4x (depending on the benchmark). Mostly ported from Unladen Swallow; initial patch by Alexandre Vassalotti.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 8732508ae2..aca8fd183c 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -1287,12 +1287,6 @@ def decode_long(data):
"""
return int.from_bytes(data, byteorder='little', signed=True)
-# Use the faster _pickle if possible
-try:
- from _pickle import *
-except ImportError:
- Pickler, Unpickler = _Pickler, _Unpickler
-
# Shorthands
def dump(obj, file, protocol=None, *, fix_imports=True):
@@ -1316,6 +1310,12 @@ def loads(s, *, fix_imports=True, encoding="ASCII", errors="strict"):
return Unpickler(file, fix_imports=fix_imports,
encoding=encoding, errors=errors).load()
+# Use the faster _pickle if possible
+try:
+ from _pickle import *
+except ImportError:
+ Pickler, Unpickler = _Pickler, _Unpickler
+
# Doctest
def _test():
import doctest