[Python-ideas] Type Hinting - Performance booster ?

Sturla Molden sturla.molden at gmail.com
Wed Dec 24 13:40:15 CET 2014


On 24/12/14 12:45, Stefan Behnel wrote:

> Regarding Cython, it's actually unlikely that it will bring anything. The
> proposed feature is about specifying Python object types for function
> arguments and (to a certain extent) local variables, and Cython is already
> pretty good in guessing those or doing optimistic optimisations that just
> say "if it looks like you're using a dict, let's generate special code that
> speeds up dict access and leaves other stuff to a fallback code path".

Numba is also very similar to Cython here. There is a set of types and 
expressions for which it can produce an efficient code path, and 
otherwise it falls back to calling the CPython interpreter. Psyco also 
used a similar strategy. This precisely where the Uladen Swallow went 
astray because they tried to accelerate any code path.

Cython's advantage is that we can mix "down to the iron" C or C++ with 
Python, without having to use or know the Python C API. And of course 
Cython is not only for speed. It is also for making it easier to write C 
or C++ extensions for any thinkable reason.


Sturla




More information about the Python-ideas mailing list