Basic optimization of python.

甜瓜 littlesweetmelon at
Mon Apr 7 07:30:50 CEST 2008

    I wonder whether python compiler does basic optimizations to .py.
t = self.a.b
t.c = ...
t.d = ...
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?
a = 1 + 2
a = 3
which one is more effective? Does the compiler calculate the result at
compile time? How about constant spreading?

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list