New issue 2186: PyPy vs CPython2 O(N^2) vs O(N) https://bitbucket.org/pypy/pypy/issues/2186/pypy-vs-cpython2-o-n-2-vs-o-n
Roman Sinayev: String concatenation seems to involve copying the whole string, while in Python2 people tend to simply add substrings. Example program: ``` import random import time def timing(f): def wrap(*args): time1 = time.time() ret = f(*args) time2 = time.time() print('%s function took %0.3f ms' % (f.__name__, (time2-time1)*1000.0)) return ret return wrap @timing def test(): s = b'' for i in range(1*1000*1000): c = chr(random.randint(1,128)) s += c return s if __name__=='__main__': test() ``` _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue