This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients larry, mark.dickinson, pitrou, rhettinger, scoder, serhiy.storchaka
Date 2015-05-06.17:37:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1430933843.12.0.175833701047.issue24138@psf.upfronthosting.co.za>
In-reply-to
Content
Here is a patch that adds a free list for 1-digit long objects.

$ ./python -m timeit -s "r = range(10**3)" -- "for i in r: pass"
Unpatched: 10000 loops, best of 3: 54.4 usec per loop
With free list: 10000 loops, best of 3: 38 usec per loop
With hacked range: 10000 loops, best of 3: 34.5 usec per loop
Python 2.7: 10000 loops, best of 3: 37.1 usec per loop

$ ./python -m timeit -s "r = list(range(10**3))" -- "for i in r: pass"
10000 loops, best of 3: 30.7 usec per loop

In Python 2.7:
$ ./python -m timeit -s "r = xrange(10**3)" -- "for i in r: pass"
10000 loops, best of 3: 41.4 usec per loop
$ ./python -m timeit -s "r = range(10**3)" -- "for i in r: pass"
10000 loops, best of 3: 37.1 usec per loop
History
Date User Action Args
2015-05-06 17:37:23serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, mark.dickinson, pitrou, scoder, larry
2015-05-06 17:37:23serhiy.storchakasetmessageid: <1430933843.12.0.175833701047.issue24138@psf.upfronthosting.co.za>
2015-05-06 17:37:23serhiy.storchakalinkissue24138 messages
2015-05-06 17:37:22serhiy.storchakacreate