SF patch #980695: efficient string concatenation
(Original patch by Armin Rigo).
This commit is contained in:
parent
2ad669666f
commit
dec5ab7a7c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue