[Python-Dev] pyc files, constant folding and borderline portability issues (original) (raw)
Paul Moore p.f.moore at gmail.com
Tue Apr 7 12:33:39 CEST 2009
- Previous message: [Python-Dev] pyc files, constant folding and borderline portability issues
- Next message: [Python-Dev] pyc files, constant folding and borderline portability issues
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2009/4/7 Cesare Di Mauro <cesare.dimauro at a-tono.com>:
The principle that I followed on doing constant folding was: "do what Python will do without constant folding enabled".
So if Python will generate LOADCONST 1 LOADCONST 2 BINARYADD the constant folding code will simply replace them with a single LOADCONST 3 When working with such kind of optimizations, the temptation is to apply them at any situation possible. For example, in other languages this a = b * 2 * 3 will be replaced by a = b * 6 In Python I can't do that, because b can be an object which overloaded the * operator, so it must be called two times, one for 2 and one for 3. That's the way I choose to implement constant folding.
That sounds sufficiently "super risk-averse" to me, so I'm in favour of constant folding being implemented with this attitude :-)
Paul.
- Previous message: [Python-Dev] pyc files, constant folding and borderline portability issues
- Next message: [Python-Dev] pyc files, constant folding and borderline portability issues
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]