[Python-Dev] Python 3000: Special type for object attributes & map keys

Tristan Seligmann mithrandi-python-dev at mithrandi.za.net
Thu Mar 20 00:30:11 CET 2008


* Neal Norwitz <nnorwitz at gmail.com> [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. :-)

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

mithrandi at elvardein:~> python2.5 -V
Python 2.5.2
mithrandi at elvardein:~> python2.5 -m timeit -s 'd = {1: None}' 'd[1]'
10000000 loops, best of 3: 0.136 usec per loop
mithrandi at elvardein:~> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/python-dev/attachments/20080320/e9a1e61f/attachment.pgp 


More information about the Python-Dev mailing list