pypy / pypy.org

Sources for website at https://www.pypy.org
33 stars 11 forks source link

Repeated string concatenation is quadratic in PyPy (and CPython) | PyPy #90

Closed utterances-bot closed 1 year ago

utterances-bot commented 1 year ago

Repeated string concatenation is quadratic in PyPy (and CPython) | PyPy

https://www.pypy.org/posts/2023/01/string-concatenation-quadratic.html

AlbertMietus commented 1 year ago

Nice & good written. Makes you think.

Also like the “explain why not fix” part

mattbillenstein commented 1 year ago

It's funny - I'm working back through old AOCs and doing this exact problem I googled for "pypy slow string concatentation" after trying ''.join(L) in the mentioned place and getting the same results...

While this use-case is perhaps pathological, I've sorta become accustomed to using += since it's often not a bottleneck in CPython since maybe about python 2.6. Having an alternate runtime with a markedly different performance result on what one might consider innocuous looking code is interesting.