I hear that python functions are compiled to bytecode as soon as they are defined.
But, according to this post, only very few optimizations are made during this step.
So, when I define this python function:
def dummy(obj):
i = obj
a = i
o = a
return o
is it not optimized to / interpreted as / equivalent to:
def dummy(obj):
return obj
by the interpreter/compiler.
As for objects member/dict access, this function:
def dummy(obj):
res = obj.member + obj.member ** 2
return [res, obj.member]
is not optimized to:
def dummy(obj):
mb = obj.member
return [mb + mb ** 2, mb]
Since python does not perform this simple job, which seems automatable yet non-trivial, are there tools to do this?