Basic optimization of python.

甜瓜 littlesweetmelon at gmail.com
Mon Apr 7 01:30:50 EDT 2008


Howdy,
    I wonder whether python compiler does basic optimizations to .py.
Eg:
t = self.a.b
t.c = ...
t.d = ...
.vs.
self.a.b.c = ...
self.a.b.d = ...
which one is more effective? Since each dot invokes a hash table lookup, it
may be time consuming. If the compiler can do expression folding, then no
manual folding is needed.

Again, how about contant calculation?
Eg:
a = 1 + 2
.vs.
a = 3
which one is more effective? Does the compiler calculate the result at
compile time? How about constant spreading?

Best regards,
---
ShenLei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080407/dddba9dd/attachment.html>


More information about the Python-list mailing list