C
Chris Angelico
While putting together some timing stats for the latest Python 3.3
string representation thread, I ran into an oddity in how IDLE handles
timeit. The normal way to profile Python code, according to stuff I've
found on the internet, is timeit.timeit:
Now I knew that the module I wanted was timeit, but I didn't remember
the full incantation, so I did the obvious thing:
Only one thing came up: Timer. And help(timeit) doesn't mention
timeit.timeit either. Whereas the documentation:
http://docs.python.org/2/library/timeit.html
http://docs.python.org/3/library/timeit.html
clearly states that timeit.timeit() is the way to do things.
Snooping the source shows that timeit.timeit() is just a tiny
convenience function (alongside timeit.repeat()), but it'd still be
nice to have that come up in the Ctrl-Space list, since it's the
most-normal way to run timing tests.
Would there be a problem with adding timeit (and possibly repeat) to __all__?
-__all__ = ["Timer"]
+__all__ = ["Timer", "timeit"]
ChrisA
string representation thread, I ran into an oddity in how IDLE handles
timeit. The normal way to profile Python code, according to stuff I've
found on the internet, is timeit.timeit:
0.57752172412974268import timeit
timeit.timeit("s=s[:-1]+u'\u1234'","s=u'asdf'*10000",number=10000)
Now I knew that the module I wanted was timeit, but I didn't remember
the full incantation, so I did the obvious thing:
Only one thing came up: Timer. And help(timeit) doesn't mention
timeit.timeit either. Whereas the documentation:
http://docs.python.org/2/library/timeit.html
http://docs.python.org/3/library/timeit.html
clearly states that timeit.timeit() is the way to do things.
Snooping the source shows that timeit.timeit() is just a tiny
convenience function (alongside timeit.repeat()), but it'd still be
nice to have that come up in the Ctrl-Space list, since it's the
most-normal way to run timing tests.
Would there be a problem with adding timeit (and possibly repeat) to __all__?
-__all__ = ["Timer"]
+__all__ = ["Timer", "timeit"]
ChrisA