timeit and __future__

K

Karl Chen

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...
 
S

Steven D'Aprano

Karl said:
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/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top