New issue 2231: List comprehensions much faster after unrolling
https://bitbucket.org/pypy/pypy/issues/2231/list-comprehensions-much-faster-after
Silvio Ricardo Cordeiro:
The following code is much faster after unrolling the list comprehension
(commenting out the first my_list line and using the second one instead):
```
#!python
indexes = range(5)
def get(i): return 42
for i in range(100*1000*1000):
my_list = [get(i) for i in indexes] # list-compr
#my_list = [get(0), get(1), get(2), get(3), get(4)] # unrolled
```
On my local machine:
```
Interpreter list-compr unrolled unrolled-with-append
PyPy 2 (v2.2.1) 7.8s 1.8s 2.9s
PyPy 2 (v4.0.1) 6.2s 1.1s 1.9s
PyPy 3 (v2.4.0) 11.3s 1.8s 2.9s
```
(The table also show results for unrolling using append instead of creating the
list in a single statement).
Are there any plans on improving list comprehensions, or is there any
limitation I'm not aware of?
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue