diff options
author | Raymond Hettinger <python@rcn.com> | 2004-08-06 18:43:09 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-08-06 18:43:09 (GMT) |
commit | 52a21b8e65e2a231595cfec639701266202438a2 (patch) | |
tree | 9c8c9ba3ea81643f19e5cd30281264bd993b6ddb /Doc/lib | |
parent | d09d9664e6a0cde5e0c7a0234ef837e11df757f1 (diff) | |
download | cpython-52a21b8e65e2a231595cfec639701266202438a2.zip cpython-52a21b8e65e2a231595cfec639701266202438a2.tar.gz cpython-52a21b8e65e2a231595cfec639701266202438a2.tar.bz2 |
SF patch #980695: efficient string concatenation
(Original patch by Armin Rigo).
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libstdtypes.tex | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex index c33360d..938dc6e 100644 --- a/Doc/lib/libstdtypes.tex +++ b/Doc/lib/libstdtypes.tex @@ -455,7 +455,7 @@ and \var{j} are integers: \lineiii{\var{x} not in \var{s}}{\code{0} if an item of \var{s} is equal to \var{x}, else \code{1}}{(1)} \hline - \lineiii{\var{s} + \var{t}}{the concatenation of \var{s} and \var{t}}{} + \lineiii{\var{s} + \var{t}}{the concatenation of \var{s} and \var{t}}{(6)} \lineiii{\var{s} * \var{n}\textrm{,} \var{n} * \var{s}}{\var{n} shallow copies of \var{s} concatenated}{(2)} \hline \lineiii{\var{s}[\var{i}]}{\var{i}'th item of \var{s}, origin 0}{(3)} @@ -536,6 +536,16 @@ In Python 2.3 and beyond, \var{x} may be a string of any length. (which end depends on the sign of \var{k}). Note, \var{k} cannot be zero. +\item[(6)] If \var{s} and \var{t} are both strings, some Python +implementations such as CPython can usally perform an inplace optimization +for assignments of the form \code{\var{s}=\var{s}+\var{t}} or +\code{\var{s}+=\var{t}}. When applicable, this optimization makes +quadratic run-time much less likely. This optimization is both version +and implementation dependent. For performance sensitive code, it is +preferrable to use the \method{str.join()} method which assures consistent +linear concatenation performance across versions and implementations. +\versionchanged[Formerly, string concatenation never occurred inplace]{2.4} + \end{description} |