[IPython-dev] timeit bug

Stefan van der Walt stefan at sun.ac.za
Tue Aug 15 12:13:50 CDT 2006


Hi all,

Can anyone confirm the following behaviour with the latest trunk?

In [1]: timeit print('x')
---------------------------------------------------------------------------
exceptions.NameError                                 Traceback (most recent call last)

/tmp/<ipython console>

/home/stefan/lib/python2.4/site-packages/IPython/iplib.py in ipmagic(self, arg_s)
    866         else:
    867             magic_args = self.var_expand(magic_args)
--> 868             return fn(magic_args)
    869
    870     def ipalias(self,arg_s):

/home/stefan/lib/python2.4/site-packages/IPython/Magic.py in magic_timeit(self, parameter_s)
   1677             for i in range(1, 10):
   1678                 number *= 10
-> 1679                 if timer.timeit(number) >= 0.2:
   1680                     break
   1681

/usr/lib/python2.4/timeit.py in timeit(self, number)
    159         gcold = gc.isenabled()
    160         gc.disable()
--> 161         timing = self.inner(it, self.timer)
    162         if gcold:
    163             gc.enable()

/tmp/<magic-timeit> in inner(_it, _timer)

NameError: global name 'x' is not defined

Regards
Stéfan


More information about the IPython-dev mailing list