performance critical Python features

Eric Snow ericsnowcurrently at gmail.com
Thu Jun 23 12:58:06 EDT 2011


I was thinking about the different features of Python that have an
impact on performance.  Here are the obvious ones I could think of:

Features most impactful on performance:

- function calls
- loops

Features least impactful on performance:

- imports
- function definitions
- class definitions

A key point is that CPython has special-case optimization for
functions (code objects, locals, and eval) and loops (comprehensions,
generators, and iterators).  Also, other libraries are optimized via
C-extensions to be efficient, I expect due to their use in loops.  In
contrast to that, the machinery behind language features like imports
are moving to pure Python.

So, which are the other pieces of Python that really need the heavy
optimization and which are those that don't?  Thanks.

-eric



More information about the Python-list mailing list