On 9/12/21 12:03 am, Steven D'Aprano wrote:
does that mean that the compiler will translate the above to:

     def eggs(a, b, c):
         def spam(*args):
             # Do something with args...
         thing = spam(a, b, c)
         ...

If that's what's intended, it wouldn't really be an inline function.
And I doubt it would make any significant difference to speed,
because looking up the function is only a small part of what makes
function calls expensive in Python -- most of it is in the parameter
processing, which can get quite complicated.

What inlining usually means is to copy the body of the function
in place of the call, with appropriate parameter substitutions.

That would eliminate most of the overhead of a function call, but
there are problems with doing it in Python. Imported modules would
have to be located and parsed at compile time, something that doesn't
currently happen. And it can't be done in general-- the location of an
imported module isn't know for sure until run time, because changes
can be made dynamically to sys.path.

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HOI6WUVSPEGJEYXEOKRTNIA42WVOZYNJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to