Serhiy Storchaka added the comment:

In response to Alexandre's comment on Rietveld. Access to a local variable is 
faster than to a global one and the current implementation uses this for 
struct.pack. I just use same trick for struct.unpack. Here is a microbenchmark 
which demonstrate some effect of this optimization. I got 0.6491418619989417, 
0.6947214259998873, and 0.5394902769985492 for optimized, non-optimized and 
advanced optimized functions.

Of course, we can achieve even better effect if we will cache not only 
struct.pack, but struct.Struct('<i').pack, struct.Struct('B').pack, etc. I were 
considered this as a reason for other patch, but we can do it in this issue.

----------
Added file: http://bugs.python.org/file29715/bench.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16551>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to