[Python-Dev] PEP 0484 - the Numeric Tower (original) (raw)

Laura Creighton lac at openend.se
Wed Oct 14 19:12:37 EDT 2015


In a message of Wed, 14 Oct 2015 23:49:33 +0100, Oscar Benjamin writes:

I'm sure the bokeh developers will be aware of the different ways that their library is used (at this level). If the input spec is "sequence of coercible to float" then I agree that they should use type annotations to match that rather than putting float and I imagine they would welcome your PR.

Guido's suggestion is not general enough for that though: what about Fraction, mpf, gmpy, numpy, sympy, h5py etc? The ABCs in the numeric tower are unused by 3rd party types making them useless for abstract type inference (IMO). AFAIK the lowest common denominator among number types in Python is the float special method. Does mypy have a way to require (a sequence of) that?

Thank you Oscar, and Chris Barker, and Guido for improving my thoughts on this matter. I go to bed now, pondering the idea that for me, internally, a new way to do type annotation 'to-x-or-is-coercible-to-x' seems a decent-enough idea. Seems a betrayal of earlier principles. Perhaps when I wake up I will feel differently. Off to dream about 'the meaning of type annotation' then. :) Thank you.

Laura



More information about the Python-Dev mailing list