Does Python allow access to some of the implementation details?

casevh at casevh at
Fri Jan 6 11:09:48 EST 2006

I don't know of a way to directly access the internal structure of a
long, but you can speed up your example.

First, is the order of the commands

>   i=i>>1
>   lstBitsBitwiseAnd.append(i&0x01)

what you intend? The first low order bit is discarded because you've
done the shift first. And an extra 0 is appended.

If you are trying to get the binary representation of a long, try
i.__hex__(). This will create a string with the hex representation.
Conversion from hex to binary is left as an exercise for the reader. :-)

More information about the Python-list mailing list