Article 51JXX [$] Reworking StringIO concatenation in Python

[$] Reworking StringIO concatenation in Python

by
jake
from LWN.net on (#51JXX)
Python string objects are immutable, so changing the value of a stringrequires that a new string object be created with the new value. That isfairly well-understood within the community, but there are some"anti-patterns" that arise; it is pretty common for new users to build up alonger string by repeatedly concatenating to the end of the "same" string.The performance penalty for doing that could be avoided by switching to atype that is geared toward incremental updates, but Python 3 hasalready optimized the penalty away for regular strings. A recent thread on the python-ideasmailing list explored this topic some.
External Content
Source RSS or Atom Feed
Feed Location http://lwn.net/headlines/rss
Feed Title LWN.net
Feed Link https://lwn.net/
Reply 0 comments