[Python-Dev] Usage of += on strings in loops in stdlib (original) (raw)

Christian Tismer tismer at stackless.com
Wed Feb 13 02:16:22 CET 2013


On 12.02.13 22:03, Maciej Fijalkowski wrote:

Hi

We recently encountered a performance issue in stdlib for pypy. It turned out that someone commited a performance "fix" that uses += for strings instead of "".join() that was there before. Now this hurts pypy (we can mitigate it to some degree though) and possible Jython and IronPython too. How people feel about generally not having += on long strings in stdlib (since the refcount = 1 thing is a hack)? What about other performance improvements in stdlib that are problematic for pypy or others? Personally I would like cleaner code in stdlib vs speeding up CPython. Typically that also helps pypy so I'm not unbiased. Cheers, fijal


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/tismer%40stackless.com

Howdy.

Funny coincidence that this issue came up an hour after I asked about string_concat optimization absence on the pypy channel.

I did not read email while writing the "efficient string concatenation" re-iteration._ _ Maybe we should use the time machine, go backwards and undo the patch, although it still makes a lot of sense and is fastest, opcode-wise, at least on CPython.

Which will not matter so much for PyPy of course because that goes away.

Alas, the damage to the mindsets already has happened, and the cure will probably be as hard as the eviction of the print statement, after all.

But since I'm a complete Python 3.3 convert (with consequent changes to my projects which was not so trivial), I think to also start publicly saying that "s += t" is a pattern that should not be used in the Gigabyte domain, from 2013.

Actually a tad, because it contradicted normal programming patterns in an appealing way. Way too sexy...

But let's toss it. Keep the past eight years in good memories as an exceptional period of liberal abuse. Maybe we should add it as an addition to the "Zen of Python": There are obviously good things, but "obvious" is the finest liar.

-- Christian Tismer :^) <mailto:tismer at stackless.com> Software Consulting : Have a break! Take a ride on Python's Karl-Liebknecht-Str. 121 : Starship http://starship.python.net/ 14482 Potsdam : PGP key -> http://pgp.uni-mainz.de phone +49 173 24 18 776 fax +49 (30) 700143-0023 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/

-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/8eb60b17/attachment.html>



More information about the Python-Dev mailing list