[Python-ideas] Why operators are useful

Rémi Lapeyre remi.lapeyre at henki.fr
Sat Mar 16 08:41:45 EDT 2019

Le 16 mars 2019 à 13:15:37, Dan Sommers
(2qdxy4rzwzuuilue at potatochowder.com(mailto:2qdxy4rzwzuuilue at potatochowder.com))
a écrit:

> On 3/16/19 6:17 AM, Richard Damon wrote:
> > On 3/16/19 4:39 AM, Greg Ewing wrote:
> >> Rémi Lapeyre wrote:
> >>> I think this omit a very important property of
> >>> mathematic equations thought, maths is a very strongly typed language
> >>> which can be a significant improvement for readability.
> >>
> >> Python is very strongly typed too, so I don't really see how
> >> maths is different.
> >
> > 'Strongly Typed Language' can have slightly different meaning to
> > different people. In Python, an object have a very definite type which
> > strongly defines what you can do with that object, while other languages
> > are less definitive in that aspect. But in Python, names are NOT that
> > strongly typed, as a name can be rebound to any sort of object with a
> > wide variety of types, compared to other languages where before using
> > (or at first use) a variable you need to declare the 'type' that will be
> > stored in it, and that type is all that it can hold.
> That's not strong vs. weak typing, that's dynamic vs. static typing.
> That said, I agree that different people get this wrong. :-)

Yes, I’m dumb. I should have wrote « maths is a static typed language ».

This together with the fact that it is nearly purely functional means that
the overhead to know what type a given symbol is is much smaller.

If I say « let f an automorphism over E », I can write three pages of equations
and f will still be the same automorphism and E its associated vector space.

I don’t have to very carefully read each intermediate result to make
sure I did not
bind f to something else.

In Python, if I write three pages of code f could be something else so
to know its
type, I must look at all intermediate lines, including the called functions to
know what the operator will refer too.

This means that the overhead to track what a given symbol is in Python and
much larger than it is in math. It’s already the case in a given function, but
it gets worse when some of the names come from arguments, then you have to look
in the caller context which may have been written at completely another time,
by another team, increasing again the overhead.

> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

More information about the Python-ideas mailing list