Strong typing implementation for Python

Todd toddrjen at gmail.com
Tue Oct 13 03:55:56 EDT 2015


On Oct 13, 2015 2:11 AM, "Steven D'Aprano" <steve at pearwood.info> wrote:
>
> On Tue, 13 Oct 2015 04:20 am, Marko Rauhamaa wrote:
>
> > As for managing complexity, many people believe static typing is a
> > crucial tool. I disagree. Static typing adds vast amounts of noise to
> > the code.
>
> Only if you are stuck in the 1970s. And even then, it is not always noise,
> type declarations or annotations often make useful documentation.
>
> Consider the following piece of code:
>
> def addone(x):
>     return x + 1
>
>
> The human programmer reading that can trivially infer that x must be a
> number (or at least something which supports numeric addition). So can the
> compiler. In a strongly typed language with no numeric promotion, the
> compiler can infer that x must be an int. In a language with numeric
> promotion, it can infer that x must be an int or float.

Or a decimal, complex number, numpy array, any one of a dozen or so pandas
classes, any one of the dozen or so units classes, sympy variable, etc...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20151013/fb1c4139/attachment.html>


More information about the Python-list mailing list