[Python-Dev] PEP 0484 - the Numeric Tower

Stephen J. Turnbull stephen at xemacs.org
Wed Oct 14 02:23:31 EDT 2015


Chris Barker - NOAA Federal writes:
 > Laura Creighton writes:

 > > I merely worry about what happens if people
 > > start relying upon the fact that a float annotation 'will handle all
 > > the numbers I care about' to the forgotten Decimal users such as
 > > myself.
 > 
 > Well, that's what you get in exchange for "type safety".

AIUI, the point of type annotations is that some use cases benefit *a
lot* from machine-parsable type information, not that type annotation
is a universally good idea in itself.  It's not type *safety* that's
the aim here.  It's type *auditability*.  If it were about "safety",
annotations would be in the interpreter, not in a separate, optional
application.

 > Which is exactly why I'm concerned about widespread use of type
 > annotations. Might as well use a static language :-(

No, no way would this satisfy static typing advocates.  Optional,
remember?

In Python, widespread use of type annotations that messes up Decimal
users would be un-Pythonic (infringes the "consenting adults"
principle).

Yes, Laura is going to run into modules that functions that have a
"float" or "Real" annotation that will complain about Decimal when
Decimal works perfectly well in that function.  Not everybody will use
annotations according to BDFL Original Intent.  But if perfectly
normal usage of Decimal or whatever runs into type annotation abuse,
and you can't simply refuse to run the type checker, I will bet that
Guido himself will be your champion.[1]

Footnotes: 
[1]  I'm not channeling anybody here, that's a statement of my
personal assessment of the real risk.  And of course it may have no
effect on the developers who use type annotations in that way, but
this is no different from any other hard to work around programming
practice.




More information about the Python-Dev mailing list