Large integers from C

Paul Rubin phr-n2002a at nightsong.com
Wed Feb 20 12:02:58 EST 2002


"Phil Mayers" <p.mayers at ic.ac.uk> writes:
> I just know someone is going to say "return the octet string and do this:
> 
> intval = reduce(lambda x,y: (x<<8)+ord(y), strval)
> 
> I've tried, and this was too slow (the whole point of the C module being
> to speed this up).
> 
> Any ideas?

Convert to hexadecimal and do intval = int(hexval, 16).
Really, no joke.



More information about the Python-list mailing list