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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:IDLE': 0.04; 'things.': 0.05; 'python': 0.09; 'convenience': 0.09; 'skip:t 60': 0.09; 'subject:module': 0.09; 'thread,': 0.09; '+__all__': 0.16; '-__all__': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oddity': 0.16; 'string': 0.17; 'tests.': 0.17; 'handles': 0.18; '>>>': 0.18; 'code,': 0.18; 'module': 0.19; 'putting': 0.20; 'import': 0.21; 'either.': 0.22; 'mention': 0.23; "i've": 0.23; 'possibly': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'run': 0.28; '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; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'wanted': 0.36; 'url:org': 0.36; 'url:library': 0.36; "didn't": 0.36; 'received:209': 0.37; 'some': 0.38; 'url:docs': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'internet,': 0.61; 'profile': 0.61; 'latest': 0.61; 'obvious': 0.71; "it'd": 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=XI65kgYnPPcHeMMkXjlRuc/yAlMtcMr92fPKraRGMzE=; b=H1lkWVZhjFPryP3YLCCm547JUxtcwckamy9lT0yPom31+KvWjOsObWW1xWOgcXnFTY 9SPadYxTDOOMqlrpgiqQ2wZpTILYETbe0BenR+ugfIPy6jVeiYSjh/eci+SvV4WQyU1h pzp8E18C7Hp+nCYPT7ItM9X5KG8imw1J7RNUNJugk+CaiFoojVWwuwNZt8rJoDyl0x6R OLKx2dp1d1IxsO1DfR/vmLLTi3NwIvE2lIn1tWIkoB12KkYD+jcDqKRvFjmtn1TLlZUk OMBPvWxFGOVfdrq/dOSUt94qWIrUiUoF8MncQjywB3QrB6k/rvZ/PIBGcDVuc7LKXXmG R3MA== MIME-Version: 1.0 X-Received: by 10.52.37.109 with SMTP id x13mr550868vdj.10.1363244319790; Wed, 13 Mar 2013 23:58:39 -0700 (PDT) Date: Thu, 14 Mar 2013 17:58:39 +1100 Subject: timeit module in IDLE From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363244328 news.xs4all.nl 6864 [2001:888:2000:d::a6]:60645 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41213 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. 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