After rereading Koos' OP, I can now see that he was referring to a
different kind of runtime type checking than I am interested in. There was
a distinction I was unaware the core typing devs make between "typing-style
types" and "classes" that I'll discuss further in the typing repo itself.
Apologies for the digression.

- Lucas

On Sun, Jun 25, 2017 at 11:13 AM, Koos Zevenhoven <k7ho...@gmail.com> wrote:

> On Sun, Jun 25, 2017 at 8:47 PM, Lucas Wiman <lucas.wi...@gmail.com>
> wrote:
>
>> > ​Yes, but then `isinstance(tuple(range(1000000)), Tuple[int, ...])`
>> would be a difficult case.
>>
>> Yes, many methods on million-element tuples are slow. :-)
>>
>> Python usually chooses the more intuitive behavior over the faster
>> behavior when there is a choice. IIUC, the objections don't have anything
>> to do with speed.
>>
>>
> ​Sure, performance cannot dictate everything. But if you look at, for
> example, that multidispatch example I wrote in the OP, it would not be wise
> to do that expensive check every time. Also, people don't expect an
> isinstance check to be expensive. But looking at annotations, it is often
> possible to get the desired answer without checking all elements in a tuple
> (or especially without consuming generators etc. to check the types).
>
> -- Koos
> ​
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to