Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41214 > unrolled thread

Re: timeit module in IDLE

Started byTerry Reedy <tjreedy@udel.edu>
First post2013-03-14 03:21 -0400
Last post2013-03-14 03:21 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: timeit module in IDLE Terry Reedy <tjreedy@udel.edu> - 2013-03-14 03:21 -0400

#41214 — Re: timeit module in IDLE

FromTerry Reedy <tjreedy@udel.edu>
Date2013-03-14 03:21 -0400
SubjectRe: timeit module in IDLE
Message-ID<mailman.3288.1363245711.2939.python-list@python.org>
On 3/14/2013 2:58 AM, Chris Angelico wrote:
> 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:
>
>>>> import timeit
>>>> timeit.timeit("s=s[:-1]+u'\u1234'","s=u'asdf'*10000",number=10000)
> 0.57752172412974268
>
> Now I knew that the module I wanted was timeit, but I didn't remember
> the full incantation, so I did the obvious thing:
>
>>>> import timeit
>>>> timeit.<ctrl-space>
>
> 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"]

I believe everything in the doc should be in __all__. Open an issue on 
the tracker and add terry.reedy as nosy.
Note on the issue that timeit.default_timer is not callable, contrary to 
the doc (which should also be fixed).

-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web