Fastest way to convert a byte of integer into a list
Paul Rubin
http
Thu Jul 12 21:05:54 EDT 2007
John Machin <sjmachin at lexicon.net> writes:
> > numlist = lookup_table[num]
> > where lookup_table is a precomputed list of lists.
> Ummm ... didn't the OP say he had 32-bit numbers???
He asked about 8 bit numbers. I saw something about 32-bit numbers
but figured those would be split into bytes or something:
(untested and I don't remember if this is the byte order wanted):
from itertools import chain
numlist = list(chain(lookup_table[(num>>i)&0xff] for i in xrange(0,32,8)))
More information about the Python-list
mailing list