Does Python allow access to some of the implementation details?
aleax at mail.comcast.net
Sat Jan 7 12:37:49 EST 2006
Claudio Grondi <claudio.grondi at freenet.de> wrote:
> What I am also looking for is a conversion to base 256 (i.e where the
> full byte is used and the string and the integer have the same actual
> content if on appropriate endian machine), which would make the bit
gmpy supplies that, too:
gmpy.binary(x) or x.binary(): returns a portable binary
representation (base-256 little endian) of an mpz object, suitable
for saving into a file (or db, whatever) -- this string can later
be passed as the first argument to function gmpy.mpz (with a
second argument with value 256) to reconstruct a copy of the
original mpz object.
> extraction comparable easy and effective as the i.__hex__() based method.
I suspect bit-extraction is still going to be faster with getbit and
friends, but I'm sure you can measure that for yourself (I'm stuck with
a loaner machine these days, and don't currently have gmpy at hand).
More information about the Python-list