SF patch #980695: efficient string concatenation

(Original patch by Armin Rigo).
This commit is contained in:
Raymond Hettinger 2004-08-06 18:47:26 +00:00
parent 2ad669666f
commit dec5ab7a7c
1 changed files with 9 additions and 0 deletions

View File

@ -521,6 +521,15 @@ Naming Conventions
Programming Recommendations
- Code should be written in a way that does not disadvantage other
implementations of Python (PyPy, Jython, IronPython, Pyrex, Psyco,
and such). For example, do not rely on CPython's efficient
implementation of in-place string concatenation for statements in
the form a+=b or a=a+b. Those statements run more slowly in
Jython. In performance sensitive parts of the library, the
''.join() form should be used instead. This will assure that
concatenation occurs in linear time across various implementations.
- Comparisons to singletons like None should always be done with
'is' or 'is not'. Also, beware of writing "if x" when you
really mean "if x is not None" -- e.g. when testing whether a