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


Groups > comp.lang.python > #41214

Re: timeit module in IDLE

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:IDLE': 0.04; 'things.': 0.05; 'python': 0.09; 'convenience': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:t 60': 0.09; 'subject:module': 0.09; 'terry': 0.09; 'thread,': 0.09; '+__all__': 0.16; '-__all__': 0.16; '__all__.': 0.16; 'callable,': 0.16; 'oddity': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'string': 0.17; 'wrote:': 0.17; 'tests.': 0.17; 'handles': 0.18; 'jan': 0.18; 'code,': 0.18; 'module': 0.19; 'putting': 0.20; 'tracker': 0.20; 'import': 0.21; 'doc': 0.22; 'either.': 0.22; 'mention': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(which': 0.26; 'am,': 0.27; 'possibly': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; 'run': 0.28; '>>>>': 0.29; 'up:': 0.29; 'source': 0.29; 'function': 0.30; 'stuff': 0.30; '(and': 0.32; 'url:python': 0.32; 'idle': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'open': 0.35; 'there': 0.35; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; 'wanted': 0.36; 'url:org': 0.36; 'url:library': 0.36; "didn't": 0.36; 'should': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'url:docs': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'header:Received:5': 0.40; 'internet,': 0.61; 'profile': 0.61; 'latest': 0.61; 'believe': 0.69; 'contrary': 0.71; 'obvious': 0.71; "it'd": 0.84; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: timeit module in IDLE
Date Thu, 14 Mar 2013 03:21:38 -0400
References <CAPTjJmoRy7yn=KfWA+kS=_RyGybN0OhE4_5wD71jPocWqAaVmw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3
In-Reply-To <CAPTjJmoRy7yn=KfWA+kS=_RyGybN0OhE4_5wD71jPocWqAaVmw@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3288.1363245711.2939.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363245711 news.xs4all.nl 6910 [2001:888:2000:d::a6]:36394
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41214

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web