timeit and __future__

Discussion in 'Python' started by Karl Chen, Jun 19, 2009.

  1. Karl Chen

    Karl Chen Guest

    I wanted to time something that uses with_statement, in python2.5.
    Importing __future__ in the statement or the setup doesn't work
    since it's not the beginning of the code being compiled. Other
    than using a separate module, I could only come up with this:

    timeit.template = 'from __future__ import with_statement\n' + timeit.template

    timeit should directly support importing __future__ stuff...
     
    Karl Chen, Jun 19, 2009
    #1
    1. Advertising

  2. Karl Chen wrote:

    >
    > I wanted to time something that uses with_statement, in python2.5.
    > Importing __future__ in the statement or the setup doesn't work
    > since it's not the beginning of the code being compiled. Other
    > than using a separate module, I could only come up with this:
    >
    > timeit.template = 'from __future__ import with_statement\n' +
    > timeit.template
    >
    > timeit should directly support importing __future__ stuff...


    Yes, it probably should. Please make a bug report/feature request at the
    Python bug tracker. If you have a patch, that would be even better.

    http://bugs.python.org/



    --
    Steven
     
    Steven D'Aprano, Jun 20, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Christensen
    Replies:
    4
    Views:
    606
    Peter Otten
    Jul 14, 2004
  2. Poor Yorick

    __future__ and unrecognised flags

    Poor Yorick, Dec 12, 2008, in forum: Python
    Replies:
    0
    Views:
    267
    Poor Yorick
    Dec 12, 2008
  3. Poor Yorick
    Replies:
    0
    Views:
    285
    Poor Yorick
    Dec 13, 2008
  4. Steve Holden
    Replies:
    1
    Views:
    404
    Rhamphoryncus
    Dec 14, 2008
  5. Mattsteel
    Replies:
    4
    Views:
    383
    Mattsteel
    Jan 30, 2010
Loading...

Share This Page