[IPython-dev] [jdc at uwo.ca: Bug#256781: ipython: funny behaviour of timeit.timeit and timeit.repeat]

Jack Moffitt jack at xiph.org
Thu Jul 1 10:56:54 EDT 2004


The following bug came into Debian a few days back, and I'd though I'd
forward it here to see if you had any ideas on what it was.  The user
made a second followup which you can find here:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256781

jack.

----- Forwarded message from Dan Christensen <jdc at uwo.ca> -----

Subject: Bug#256781: ipython: funny behaviour of timeit.timeit and
	timeit.repeat
From: Dan Christensen <jdc at uwo.ca>
To: Debian Bug Tracking System <submit at bugs.debian.org>
Date: Mon, 28 Jun 2004 21:48:50 -0400
Resent-Sender: Debian BTS <debbugs at bugs.debian.org>

Package: ipython
Version: 0.6.0-1
Severity: normal

[I manually changed the input prompts to >>> and removed the
output labels.]

On a 2.0GHz P4 laptop (speedstep disabled) running mostly testing:

Python 2.3.4 (#2, May 29 2004, 03:31:27) 
Type "copyright", "credits" or "license" for more information.

IPython 0.6.0 -- An enhanced Interactive Python.

>>> from timeit import *
>>> from time import *
>>> t=Timer("pass","pass",timer=time)
>>> t.timeit(1000000)
0.15831089019775391
>>> t.repeat(1,1000000)
[0.079621076583862305]

Note the factor of two difference!  It's consistent:

>>> t.timeit(1000000)
0.14923691749572754
>>> t.repeat(1,1000000)
[0.080674886703491211]
>>> for i in range(3):
...     t.timeit(1000000)
0.15053701400756836
0.15190696716308594
0.15034103393554688
>>> t.repeat(3,1000000)
[0.080902099609375,
 0.081040859222412109,
 0.080629110336303711]

And it happens with timer=clock too:

>>> t2=Timer("pass","pass",timer=clock)
>>> t2.timeit(1000000)
0.11000000000000032
>>> t2.repeat(3,1000000)
[0.079999999999999627, 0.080000000000000071, 0.090000000000000302]

It also happens with statements other than "pass".  The ratio is
different then, and sometimes the repeat version takes longer
(in one case, consistently 20% longer).

This doesn't happen when the above is run in plain python.

And it doesn't happen using ipython on a dual Xeon machine I have
access to, which also runs Debian testing.

Any ideas what's up?  I've looked at timeit.py and can't see how this
is possible...  Let me know if I can help debug it.

Dan


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.4.26
Locale: LANG=C, LC_CTYPE=C

Versions of packages ipython depends on:
ii  python                        2.3.4-1    An interactive high-level object-o

-- no debconf information

----- End forwarded message -----




More information about the IPython-dev mailing list