inline function call

Christopher Subich csubich.spam.block at spam.subich.block.com
Thu Jan 5 09:27:09 EST 2006


Diez B. Roggisch wrote:
> No. That is simply impossible in python as well as in java where functions
> are always virtual, meaning they are looked up at runtime. Because you'd
> never know _which_ code to insert of all the different foo()-methods that
> might be around there.

Not quite "simply impossible" -- inlining function/method calls could 
indeed be an optimization done (eventually) by PyPy or another 
Psyco-like optimizer.  In this case, function inlining is just something 
that You Can Do if you dynamically determine that the function is a 
constant object.

Since it is an optimization that makes an assumption about the constancy 
of an object, this wouldn't hold true in the general case; an 
interpreter which makes that dynamic optimization would need some degree 
if checks to make sure that the assumption remains valid.

So it's not technically impossible, at least in the majority of cases 
where functions are neither modified nor rebound, no current python 
interpreter makes that assumption.



More information about the Python-list mailing list