2's complement conversion. Is this right?

Ross Ridge rridge at caffeine.csclub.uwaterloo.ca
Sun Apr 20 01:00:17 EDT 2008


Ross Ridge <rri... at caffeine.csclub.uwaterloo.ca> wrote:
> It's the same as the previous version except that it "precompiles"
> the struct.unpack() format string. =A0It works similar to the way Python
> handles regular expressions.

George Sakkis  <george.sakkis at gmail.com> wrote:
>I didn't know about the Struct class; pretty neat. It's amazing that
>this version without Psyco is as fast Bob's version with Psyco!

Unfortunately, it doesn't seem to documented in the Python 2.5 manual.
The speed improvement mainly comes from avoiding the Python code in the
struct module that wraps the Struct class.  The struct module caches
already compiled format strings, but looking format strings in the cache
ends taking a fair chunk of time in my original example.

				Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge at csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  



More information about the Python-list mailing list