* Neal Norwitz <[EMAIL PROTECTED]> [2008-03-18 18:54:47 -0500]:

> First, you should measure the current speed difference.  Something like:
> 
> $ ./python.exe -m timeit -s 'd = {1: None}' 'd[1]'
> 1000000 loops, best of 3: 0.793 usec per loop
> $ ./python.exe -m timeit -s 'd = {"1": None}' 'd["1"]'
> 1000000 loops, best of 3: 0.728 usec per loop
> 
> My python is a debug version, so a release version might be faster for
> ints.  If not, the first task would be to speed up int lookups. :-)

[EMAIL PROTECTED]:~> python -V
Python 2.4.5
[EMAIL PROTECTED]:~> python -m timeit -s 'd = {1: None}' 'd[1]'
10000000 loops, best of 3: 0.142 usec per loop
[EMAIL PROTECTED]:~> python -m timeit -s 'd = {"1": None}' 'd["1"]'
10000000 loops, best of 3: 0.138 usec per loop

[EMAIL PROTECTED]:~> python2.5 -V
Python 2.5.2
[EMAIL PROTECTED]:~> python2.5 -m timeit -s 'd = {1: None}' 'd[1]'
10000000 loops, best of 3: 0.136 usec per loop
[EMAIL PROTECTED]:~> python2.5 -m timeit -s 'd = {"1": None}' 'd["1"]'
10000000 loops, best of 3: 0.126 usec per loop
-- 
mithrandi, i Ainil en-Balandor, a faer Ambar

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to