Aber wenn man mal sehen will wie sich python in der Performance weiterentwickelt hat.. hier nochmal die Benchmarks mit python2.7, python3 und pypy.
Die Itertools Variante hat unter pypy eine Regression, für pypy müsste wohl der Code nochmals eigens optimiert werden .. keine meiner Varianten toppt die Referenzimplementierung unter pypy.
Interessant.. kann jemand diese Messungen bestätigen ?
PS: Ich hab nochmal den Code für eine numpy Variante angehängt.
Gemmesen unter Debian 8.6 auf:
Code: Alles auswählen
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
stepping : 11
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Code: Alles auswählen
timeit
timeit
timeit
referenz: 26.433770895
vanilla: 5.74793505669
itertools: 2.98172211647
numpy: 1.80512595177
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Code: Alles auswählen
timeit
timeit
referenz: 23.37278415900073
vanilla: 5.743356631006463
itertools: 2.427294566994533
numpy: 1.89215411299665
Python 2.7.8 (2.4.0+dfsg-3, Dec 20 2014, 13:30:46)
[PyPy 2.4.0 with GCC 4.9.2] on linux2
Code: Alles auswählen
timeit
referenz: 3.46602106094
vanilla: 3.57421088219
itertools: 10.3857440948