[PyAR2] Programming Challenge II - One is the Magic Number

W W srilyk at gmail.com
Tue Oct 28 14:05:30 CET 2008


On Tue, Oct 28, 2008 at 7:53 AM, W W <srilyk at gmail.com> wrote:

> <snip>I'm not sure how long it takes one vs. the other, but I'm sure it's
> orders of magnitude!
>

I think I'm using timeit right...:


In [9]: x = timeit.Timer('for i in range(1,1000000): pass')

In [10]: t = timeit.Timer('for i in xrange(1,1000000): pass')

In [11]: x.timeit(10)
Out[11]: 1.8295149803161621

In [12]: t.timeit(10)
Out[12]: 0.95827603340148926

In [13]: t.timeit(20)
Out[13]: 2.1089239120483398

In [14]: x.timeit(20)
Out[14]: 2.7574639320373535

In [15]: x.timeit(100)
Out[15]: 12.90097188949585

In [16]: t.timeit(100)
Out[16]: 8.7963299751281738


So that yeilds some interesting results (if I'm using the thing correctly):
on 10 passes, it's about double the time. 20 passes it's a little less than
1.5x more, and 100 passes it's nearly 1.5 times more. I'm sure if someone
cared enough they could either install matplotlib or at least write out a
list of tuples with the coords. Actually I think I'll do that now ;)

-Wayne

-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/pyar2/attachments/20081028/e7b6c0a6/attachment.htm>


More information about the PyAR2 mailing list