[IPython-dev] timeit bug

Ville M. Vainio vivainio at gmail.com
Thu Sep 21 03:56:51 CDT 2006


On 9/15/06, Stefan van der Walt <stefan at sun.ac.za> wrote:

Hi,

If you need this to work quickly, do

timeit print(\'x\')

i.e. escape the quotes.

Using parse_options is a bad idea in timeit because it gets rid of the
quotes. It needs to be fixed properly, but I suggest using backslashes
to get over the immediate problem.


> Unfortunately, I don't seem to have permission to create tickets on
> the ipython trac -- which is why I am re-posting this.  Has anyone
> taken a look at it by any chance?
>
> Regards
> Stéfan
>
> ----- Forwarded message from Stefan van der Walt <stefan at sun.ac.za> -----
>
> From: Stefan van der Walt <stefan at sun.ac.za>
> To: ipython-dev at scipy.org
> Subject: timeit bug
> Date: Tue, 15 Aug 2006 19:13:50 +0200
> User-Agent: Mutt/1.5.11
> Message-ID: <20060815171350.GA32301 at mentat.za.net>
>
> 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
>
> ----- End forwarded message -----
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/ipython-dev
>


-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'


More information about the IPython-dev mailing list