[Python-Dev] pyc files, constant folding and borderline portability issues

skip at pobox.com skip at pobox.com
Mon Apr 6 18:57:44 CEST 2009

    Cesare> At this time with Python 2.6.1 we have these results:
    Cesare> def f(): return 1 + 2 * 3 + 4j
    Cesare> def f(): return ['a', ('b', 'c')] * (1 + 2 * 3)

Guido can certainly correct me if I'm wrong, but I believe the main point of
his message was that you aren't going to encounter a lot of code in Python
which is amenable to traditional constant folding.  For the most part, they
will be assigned to symbolic "constants", which, unlike C preprocessor
macros aren't really constants at all.  Consequently, the opportunity for
constant folding is minimal and probably introduces more opportunities for
bugs than performance improvements.


More information about the Python-Dev mailing list