Basic optimization of python.

Hrvoje Niksic hniksic at xemacs.org
Wed Apr 9 08:03:14 EDT 2008


"Diez B. Roggisch" <deets at nospam.web.de> writes:

>> 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?
>
> Algebraic optimizations aren't done AFAIK

Just try it:

Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> dis.dis(lambda: 10+5)
  1           0 LOAD_CONST               2 (15)
              3 RETURN_VALUE        



More information about the Python-list mailing list