fastest table lookup
Peter Otten
__peter__ at web.de
Mon Oct 25 15:23:12 EDT 2004
Neal D. Becker wrote:
> I need a fairly small lookup table, and I'm wondering which data python
> data
> structure would be fastest. I could use a list, tuple, dictionary,
> numeric
> array, or maybe plain python array. The table would be indexed by simple
> integers and would be dense (filled).
Here are some 2.3 timings to give you a head start:
$ python timeit.py -s"a = [1]" "a[0]"
1000000 loops, best of 3: 0.177 usec per loop
$ python timeit.py -s"a = 1," "a[0]"
1000000 loops, best of 3: 0.196 usec per loop
$ python timeit.py -s"a = {0:1}" "a[0]"
1000000 loops, best of 3: 0.21 usec per loop
Peter
More information about the Python-list
mailing list