[pypy-issue] Issue #2750: array resize through slice assignment slow (pypy/pypy)

Christoph Reiter issues-reply at bitbucket.org
Wed Feb 7 09:17:32 EST 2018


New issue 2750: array resize through slice assignment slow
https://bitbucket.org/pypy/pypy/issues/2750/array-resize-through-slice-assignment-slow

Christoph Reiter:

```
#!python

import array

def x(n):
    data = array.array('B')
    for i in range(n):
        data[i:i+1] = array.array("B", [0])

x(20000)
```

With CPython the time per assignment with increasing "n" stays constant, while in PyPy it increases with "n".

There is no real use case behind this, as I can easily preallocate the array which makes things work. I just noticed that one of my test cases got stuck under pypy because it resized an array 100000 times, and with CPython this was near instant.




More information about the pypy-issue mailing list