[issue1569040] Speed up using + for string concatenation

Larry Hastings report at bugs.python.org
Tue Mar 31 16:38:29 CEST 2009


Larry Hastings <larry at hastings.org> added the comment:

rhettinger: It's a bit unfair to paint the lazy string concatenation
patch with the adjective "ropes", then point out ropes have been
rejected many times.  Lazy string concatenation objects are a form of
specialized rope but they don't share the downsides of these other
"ropes" proposals.

The major problems with conventional rope implementations are a)
slowdown, b) complexity, and c) you must use a new API to interact with
them:
http://mail.python.org/pipermail/python-dev/2000-February/002321.html

Lazy string concatenation makes Python faster, it isolates its
complexity locally inside the string object implementation, and it makes
only two changes to the API.  Those two changes are: one, you may no
longer access the string directly, and two, APIs that returned the
internal string (PyString_AsString, PyString_AS_STRING*) may fail in
low-memory conditions.  You don't need to use a new API to interact with
the string; traditional APIs like strchr work fine.

* Those were the names in 2.6 anyway.  I don't know what the modern
names would be in 3.1.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1569040>
_______________________________________


More information about the Python-bugs-list mailing list