[Python-Dev] tuple[int] optimization
Antoine Pitrou
solipsis at pitrou.net
Sun Jul 24 02:18:23 CEST 2011
Le dimanche 24 juillet 2011 à 03:15 +0300, Andrew Svetlov a écrit :
> You right. Sorry, I missed changes in ceval.c for py3k.
> Please note, simple test like:
>
> from timeit import timeit
>
> print('list', timeit("l[0]", "l = [1]"))
> print('tuple', timeit("l[0]", "l = (1,)"))
>
> Has results:
>
> andrew at ocean ~/p/cpython> python2.7 z.py
> ('list', 0.03479599952697754)
> ('tuple', 0.046610116958618164)
>
> andrew at ocean ~/p/cpython> python3.2 z.py
> list 0.04870104789733887
> tuple 0.04825997352600098
>
> For python2.7 list[int] microoptimization saves 25-30%, while 3.2 (and
> trunk) very close to "unoptimized" 2.7 version.
My point is that on non-trivial benchmarks, the savings are almost zero.
If you look at the (much more complex) patch I linked to, the savings
are at most 10% on a couple of select benchmarks, other benchmarks
showing almost no difference.
Regards
Antoine.
More information about the Python-Dev
mailing list