[pypy-issue] [issue1432] set(xrange(n)) is slower than set(range(n))

mrjbq7 tracker at bugs.pypy.org
Mon Mar 25 04:48:06 CET 2013


New submission from mrjbq7 <mrjbq7 at gmail.com>:

Using this test script:

```
import time

t0 = time.time()
s1 = set()
for i in xrange(5000000):
    s1.add(i)
t1 = time.time()
s2 = set(xrange(5000000))
t2 = time.time()
s3 = set(range(5000000))
t3 = time.time()

print 'add one took %.3f seconds' % (t1-t0)
print 'add all xrange took %.3f seconds' % (t2-t1)
print 'add all range took %.3f seconds' % (t3-t2)
```

The performance on a recently nightly build is:

```
$ ./pypy-c-jit-61334-6bf80dae95f7-osx64/bin/pypy baz.py 
add one took 0.189 seconds
add all xrange took 0.419 seconds
add all range took 0.207 seconds
```

----------
messages: 5505
nosy: mrjbq7, pypy-issue
priority: performance bug
status: unread
title: set(xrange(n)) is slower than set(range(n))

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1432>
________________________________________


More information about the pypy-issue mailing list