Okay well in C++ there is normal functions and "inline" functions, my question is: are there inline functions in python?
Okay well in C++ there is normal functions and "inline" functions, my question is: are there inline functions in python?
Those people who think they know everything are a great annoyance to those of us who do.
Dietrich, you can also find that out by looking on MSDN. monkeyman, I don't know much C++, so I probably couldn't help you with this. You would probably have to edit the source, which would most likely be a lot of work.
ya so i better don't try because it was just an idea
Those people who think they know everything are a great annoyance to those of us who do.
In C or C++ an inline function is one where the body of the function is placed directly at the place it is called, instead of being a separate subroutine. This is marginally faster, since there is no overhead of jumping to a new address, pushing registers on the stack, and returning at the end.
There is no equivalent in Python, but you could simulate it by using a pre-processor to define macros - this is what C did (and often still does, although the inline keyword was introduced in C99), and would be pretty simple to implement. You could either write a custom pre-processor in Python or use an existing one such as cpp or M4.
Alternatively you could write an inline optimiser that reads python bytecodes (.pyc files) or ASTs and inlines functions where possible. This would be much harder to do, but closer to what C++ inlining does.
Dave - The Developers' Coach
Last edited by DevCoach; June 4th, 2005 at 05:54 PM.
lamda is more of a unnamed function, not really an inline one, even though it is kinda in the same place and such. However being how python is interprited, it wont matter with using inline compared to none inline functions. Unless you rewrite the interpriter to do so.
My Site:
http://www.coryhardman.com
I don't understand the point of lambda functions in months I have not even seen them
Those people who think they know everything are a great annoyance to those of us who do.
there really isn't anything that is really "needed" by them. Everything you can do with lamda you can with a ruglar function. It just lets you put more things in one line instead of a few. With python 3.0 it is plained to be taken out. Personly, i have never seen them used in any large projects and I have never used one. Mainly because I think they are ugly
My Site:
http://www.coryhardman.com
I agree they are ugly:P And me too I have never used one
Those people who think they know everything are a great annoyance to those of us who do.