[SciPy-User] & lt; transferred from Scipy-Dev& gt; Re: Seeking help/ advice for applying functions

Anne Archibald peridot.faceted@gmail....
Tue Mar 9 19:46:10 CST 2010


On 9 March 2010 18:06, eat <e.antero.tammi@gmail.com> wrote:
> Anne Archibald <peridot.faceted <at> gmail.com> writes:
>
>> 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.
>>
> OK. I kind of understand, but wouldn't it possible to somehow sidetrack this
> whole dynamic nature of python (when really needed)? Perhaps giving some kind
> of exclusive gateway to the underlying libraries. Yes, I'm considering here
> only the mature libraries, where no API changes are expected.

It's not just a question of libraries but also of data representation
- do you annotate every floating point value with a tag that says "I'm
a floating-point value" or not? - but yes, that's exactly what cython,
f2py, swig, and all the other python interfacing tools are for. The
general philosophy with python has always been "use python where you
need flexibility and convenience; where you need speed call into
compiled code". This is great because for many (most?) programs the
part that actually needs to be fast is a small fraction of the total
lines of code, and the rest becomes easier to write and debug when you
do it in python.

Anne


More information about the SciPy-User mailing list