[Dailydave] Why you care about this sort of Python bug.

Imri Goldberg lorgandon at gmail.com
Tue Apr 1 18:43:11 EDT 2008


Dave Aitel wrote:
> As many people noticed, this is it. Essentially the following line is
> equivalent with strdup(data+1024).
> ~            data=data[1024:]
>
> Below you can see an exponential increase in time...
You cheated a little bit here - you gave it exponential increasing size 
of input.
The time should grow only by O(n^2), which is still slow enough :)

> $ time python /tmp/test.py 1000
> user    0m0.019s
>
> $ time python /tmp/test.py 10000
> user    0m0.043s
>
> $ time python /tmp/test.py 100000
> user    0m2.251s
>
> $ time python /tmp/test.py 1000000
> user    6m45.435s
>
> Code for test.py:
> import sys
> count=int(sys.argv[1])
> data="A"*count
> for i in xrange(len(data)):
> ~   data=data[1:]
Cheers,
Imri
-------------------------
Imri Goldberg
www.algorithm.co.il/blogs
www.imri.co.il
-------------------------
Insert Signature Here
-------------------------



More information about the Dailydave mailing list