Converting a hex string to a number
Alex Martelli
aleax at aleax.it
Tue Jul 9 11:21:49 EDT 2002
me wrote:
...
> Like this solution. Is there a way to use that long as hex, so bit
> operations can be done on it piecewise? Slice a byte, then xor it or
> and it, and put it back?
Longs, like ints and other kinds of numbers, are immutable -- so each
time you change even one bit you're allocating a new one and copying
all the rest. Use an array.array with a typecode of 'B' (unsigned bytes),
it may prove substantially better-performing as it's mutable.
Alex
More information about the Python-list
mailing list