Use more efficient pickle protocol for caching specs file
---------------------------------------------------------

                 Key: QPID-2712
                 URL: https://issues.apache.org/jira/browse/QPID-2712
             Project: Qpid
          Issue Type: Improvement
          Components: Python Client
    Affects Versions: 0.7
            Reporter: Jeff Laughlin
            Priority: Trivial


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
 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to