Hi,
I have read the part about "Avoiding dots
<https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Avoiding_dots...>"
on the python.org Performance tips web page.
Even if I understand the concept, I wanted to check the example and ran the
attached program. It shows the "optimized" example to be slower than the
non-optimized one.
Who could I discuss that issue with?
Thank you very much
Regards
Sébastien Aubry
#!/usr/bin/env python
# coding: utf-8
import timeit
def f():
upper = str.upper
newlist = []
append = newlist.append
for i in range(100000):
append(upper("word"))
def g():
newlist = []
append = newlist.append
for i in range(100000):
newlist.append("word".upper())
print(timeit.timeit('f()', setup="from __main__ import f", number=100))
print(timeit.timeit('g()', setup="from __main__ import g", number=100))
_______________________________________________
pydotorg-www mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pydotorg-www