[Numpy-discussion] Type annotations for NumPy
Juan Nunez-Iglesias
jni.soma at gmail.com
Sat Nov 25 20:31:07 EST 2017
On 26 Nov 2017, 12:27 PM +1100, Nathaniel Smith <njs at pobox.com>, wrote:
> It turns out that the PEP 484 type system is *mostly* not useful for
> this. They're really designed for checking consistency across a large
> code-base, not for enabling compiler speedups. For example, if you
> annotate something as an int, that means "this object is a subclass of
> int". This is enough to let mypy catch your mistake if you
> accidentally pass in a float instead, but it's not enough to tell you
> anything at all about the object's behavior -- you could make a wacky
> int subclass that acts like a string or something.
But doesn’t Cython do all kinds of type conversions and implied equivalences that could be applied here? e.g. I’m going to annotate this as int, which might mean whatever in mypy, but if I pass this .py file to a newfangled Cython 0.35 compiler, the compiler will understand this to mean “actually really this is an int”?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20171126/da474993/attachment.html>
More information about the NumPy-Discussion
mailing list