Python is DOOMED! Again!

Rustom Mody rustompmody at gmail.com
Thu Jan 22 22:11:11 EST 2015


On Friday, January 23, 2015 at 3:50:38 AM UTC+5:30, Ian wrote:
> On Thu, Jan 22, 2015 at 3:08 PM, Ian Kelly  wrote:
> > On Thu, Jan 22, 2015 at 2:56 PM, Emile van Sebille  wrote:
> >> I've been lightly scanning and following the PEP 484 discussion, and one
> >> point I don't think I've seen mentioned is how you might hint a function
> >> that accepts different types, eg:
> >>
> >> def adder(a,b): return a+b
> >>
> >> This is one of the pythonic idioms that help with polymorphic functions.  Is
> >> there a proposal for providing hinting for these?
> >
> > You can use TypeVar for that.
> >
> > T = TypeVar('T')
> >
> > def adder(a: T, b: T) -> T:
> >     return a + b
> >
> > I'm not thrilled about having to actually declare T in this sort of
> > situation, but I don't have a better proposal.
> 
> Hmm, but also that hinting doesn't cover cases like adder(12, 37.5)
> where two different types can be passed, and the return type could be
> either. I think for full generality you would just have to forgo
> hinting on this function.

You are 'discovering' two bugs in python's design:
1. [1,2,3] + [4,5,6]
uses the same symbol for an unrelated operation 
1 + 4

2. 1 + 2.14
has an implicit conversion

The second is present in almost all languages so its best called 'feature' not bug

The first I expect will incur costs that are way out of proportion to the benefits



More information about the Python-list mailing list