Details
-
Improvement
-
Status: Closed
-
Trivial
-
Resolution: Won't Fix
-
0.7
-
None
-
None
Description
By default, pickle uses protocol 0. This is text based and relatively slow. Calling pickle.dump with -1 as the 3rd argument, python will use the highest available pickle protocol, typically protocol 2 since python 2.3, which is binary, and relatively fast (and uses less space). When loading, pickle automatically determines what format was used to dump.
There's really no reason NOT to use the highest protocol in this application. This isn't for data interchange. Since this is for local caching only, it's unlikely that saving in the highest pickle version would ever cause a backwards compatibility issue. Maybe if somebody was using two drastically different versions of python on the same system...
See also http://www.python.org/dev/peps/pep-0307/
This requires changing one line of code.
— qpid/ops.py (revision 959828)
+++ qpid/ops.py (working copy)
@@ -260,7 +260,7 @@
types = load_types_from_xml(file)
if os.access(os.path.dirname(os.path.abspath(pclfile)), os.W_OK):
f = open(pclfile, "wb")
- pickle.dump(types, f)
+ pickle.dump(types, f, -1)
f.close()
return types