How to Read Bytes from a file

Matthias Julius jnews at julius-net.net
Tue Mar 6 15:07:45 EST 2007


"Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> writes:

> En Fri, 02 Mar 2007 08:22:36 -0300, Bart Ogryczak
> <B.Ogryczak at gmail.com> escribió:
>
>> On Mar 1, 7:36 pm, "gregpin... at gmail.com" <gregpin... at gmail.com>
>> wrote:
>>> Thanks Bart.  That's perfect.  The other suggestion was to precompute
>>> count1 for all possible bytes, I guess that's 0-256, right?
>>
>> 0-255 actually. It'd be worth it, if accessing dictionary with
>> precomputed values would be significantly faster then calculating the
>> lambda, which I doubt. I suspect it actually might be slower.
>
> Dictionary access is highly optimized in Python. In fact, using a
> precomputed dictionary is about 12 times faster:

Why using a dictionary and not a list?

Matthias



More information about the Python-list mailing list