New issue 1925: VERY slow string concatenation
https://bitbucket.org/pypy/pypy/issue/1925/very-slow-string-concatenation
Yichao Yu:
The following script (admittedly not the best way to build long string) runs
~30-100 times slower on pypy than cpython2/3.
```python
a = ''
for i in range(10000):
a += 'a'
```
PyPy version: a772923edb32 (latest as of last week) on my laptop.
```
% python -m timeit -s 'a = ""' -- "for i in range(10000): a += 'a'"
1000 loops, best of 3: 1.07 msec per loop
```
```
% python2 -m timeit -s 'a = ""' -- "for i in range(10000): a += 'a'"
1000 loops, best of 3: 678 usec per loop
```
```
% pypy -m timeit -s 'a = ""' -- "for i in range(10000): a += 'a'"
10 loops, best of 3: 29.6 msec per loop
```
PyPy 2.4.0 on a linode vps is even worse
```
% python -m timeit -s 'a = ""' -- "for i in range(10000): a += 'a'"
1000 loops, best of 3: 1.55 msec per loop
```
```
% python2 -m timeit -s 'a = ""' -- "for i in range(10000): a += 'a'"
1000 loops, best of 3: 978 usec per loop
```
```
% pypy -m timeit -s 'a = ""' -- "for i in range(10000): a += 'a'"
10 loops, best of 3: 94.6 msec per loop
```
The time might not be accurate since the script does not run for very long
(~1s) but the significant slow down remains when repeating this multiple time
and with more iteration in the loop.
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue