[Python-Dev] PEP 0484 - the Numeric Tower

Laura Creighton lac at openend.se
Wed Oct 14 18:04:43 EDT 2015


In a message of Wed, 14 Oct 2015 21:21:30 -0000, Oscar Benjamin writes:
>Generally if it's possible to interchange floats and decimals in your code
>then there's probably no need for decimals in the first place. 

Yes, but, at least around here the common case is that you already 
_have_ a pile of decimals (extracted from your leger) and now you
want to do something with them (like graph them and make reports
out of the graphs) with other people's graphing and report generating
software. 

>If mypy
>requires you to do an explicit conversion to float then there may be some
>seld-documenting merit in showing that conversion up front rather than
>assuming that it's okay to insert decimals where they're not expected. The
>point of static type checking is to detect precisely these kinds of errors.

The thing is that there is a very big split between code written as
'this is a float using function and decimal users very much have to 
avoid using it' and 'this thing works perfectly well for floats and 
decimals'.  That code writers in the scientific python world mostly
never think of Decimal users, doesn't mean they don't end up writing
perfectly wonderful tools and libraries we use. :)  thankfully :)

I was looking for a way for the Python type hinting to be expressive
enough to handle this common (at least in my world) case.  So then,
even if the bokeh developers (just to pick some friends) forget about
me in their type annotations, I can just make a pull request, send it
back with some corrected annotations and the note 'remember me!' :)

>Oscar

Laura




More information about the Python-Dev mailing list