[SciPy-User] < transferred from Scipy-Dev> Re: Seeking help/ advice for applying functions
Tue Mar 9 15:56:33 CST 2010
On 9 March 2010 16:50, eat <firstname.lastname@example.org> wrote:
> Robert Kern <robert.kern <at> gmail.com> writes:
>> On Tue, Mar 9, 2010 at 13:51, eat <e.antero.tammi <at> gmail.com> wrote:
>> > Not only that I'm new to Scipy/ Numpy but I'm new to python aswell.
>> > I think I assumed that once python functions get compiled they'll would be
>> > (almost) as efficient than builtins.
>> No, not at all. Python functions do not get compiled to machine code.
>> They get compiled to Python bytecode, but that Python bytecode is
>> interpreted. Python functions have tons of overhead compared to
> Aha, so python does not have a mechanism to optimize bytecode (nor higher
> level code) inorder to get rid off the dynamic nature of code when needed.
This kind of optimization is extremely difficult; it involves, for
example, inferring that a particular variable will always point to an
integer value, so that the type information attached to the integer
can be discarded. There are languages/programming environments that
are capable of this, but it is a difficult and expensive operation.
It's also unlikely to be productive for python, which is very dynamic,
as languages go: the value "None" is often used to signify "no answer
yet" in variables that would otherwise point to only one type of
value, and it's perfectly acceptable to change what function
"mymodule.myfunction" points to at any point.
More information about the SciPy-User