[Python-Dev] PEP 0484 - the Numeric Tower

Chris Barker - NOAA Federal chris.barker at noaa.gov
Wed Oct 14 20:45:55 EDT 2015

> Yes, but what I expect the type annotations to be used for, especially
> in the SciPy world, is to make things easier for Numba to generate fast
> code.

Well, probably not.

There are two reasons to have type declarations: performance and type safety.

But the current type annotations are designed only for the latter. A
number of us brought this up in the discussion because we do, in fact,
want the magic fairy dust of faster code, whether by numba or
Cython(my favorite) and I had hoped that type annotations would be
useful for that. But it was explicitly stated that that was not the
intent. And indeed, if you want to preserve any of python's nifty
dynamic typing ( and we all do ) it can't support truly static typing.

I.e. In Python, you want to say that your function works with, say, a
sequence of numbers. But for performant compilation, you'd need to
know the binary layout of that sequence.

Side notes:

Numba does JIT compilation, so pre specifying the types isn't needed
anyway. Certainly adding these type annotations will buy you nothing.

Bokeh, on the other hand, has to pass everything off to the browser
anyway, presumably with JSON, so in theory it shouldn't need Numpy
arrays anyway.

(Of course, JSON doesn't support Decimal anyway -- or, strictly
speaking, only supports decimal, but JavaScript conveys it to

>  I really hope that the SciPy world is not going to go nuts for
> useless annotations, but I have, alas, all too many years dealing with
> people whose desire to have faster code vastly outstrips their ability
> to understand just what is possible in that regard.
> In James Barrie's novel, Peter Pan, earthly children are given the
> ability to fly by having Fairy Dust (supplied by the unwilling
> Tinkerbell) sprinkled over them.  I now know that what a large number
> of people who want faster code, really want is magic Fairy Dust.  They
> wanted psyco to be it, they wanted pypy to be it, and now they want
> Numba to be it.  The notion that sprinkling type annotations all over
> their code will make it fly _absolutely deeply resonates_ with how
> these people wish the world worked.  They will believe that type
> annotations are magic fairy dust until they are forced to confront
> the fact poorly written code can not be made fly until it is rewritten.
> Laura
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov

More information about the Python-Dev mailing list