The Voidspace Techie Blog

A long time ago there was http:// bytecodehacks.sourceforge...cks.inline.html


Gravatar One of the complaints about C++ inlining is that it's done in the wrong place. It makes more sense to decide at the call site than the definition site, or so they say.


Gravatar I think in Python the decision about inlining a function would have to be made in the place where the function is used. Besides, the possible scope of inlining would also be limited:

- no functions imported from other modules (what if we distribute a .pyc and the imported module changes?),
- no class methods (what happens if we override the inlined function in a derived class?).

That basically leaves us to module-level functions and functions defined in the local scope.

I would suggest a decorator called __inline__.

Other optimizations could include for-loop unrolling for short, fixed iterators (fixed range or literal tuple with fixed values).


Name:

Email:

URL:

Comment:  ? 

 

Commenting by HaloScan