[Python-Dev] Optimization
Raymond Hettinger
raymond.hettinger at gmail.com
Sun Oct 6 00:35:30 CEST 2013
On Oct 5, 2013, at 12:42 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> Please remember me, what was common decision about CPython-only optimizations which change computation complexity?
IIRC, it is okay optimize C code for just about anything, but we don't
want to alter the pure python code after from idiomatic solutions that
work on all of the implementations.
For example, there is a string concatenation optimization
in the C code, but we still use and advocate str.join()
and try not to write code that relies on the optimization.
That said, it is nice that less informed users are sometimes
saved from an accidental performance trap.
Making bytearray's efficiently pop from the left side is dubious.
This isn't a common idiom, nor should it be. Even if all the
other implementations could model this behavior, it wouldn't
be a good idea to have bytearrays have different performance
characteristics than strings. Right now, it is not too hard to
roughly explain the performance characteristics of the various
container objects, but that would be imperiled a bit by having
bytearrays differing from strings in ways other than their size.
Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131005/3b95665d/attachment.html>
More information about the Python-Dev
mailing list