Shantanu <hauntsani...@gmail.com> added the comment:

My implementation in PR 22848 turns callable into a type and uses `__new__`. It 
isn't too bad. It does appear to affect performance of callable though.

Here's some data on how often typing imports are used. This is the number of 
files in which `from typing import X` is present in mypy_primer's corpus 
(searched using the AST). My read of this is that Callable is meaningfully more 
used than anything else in collections.abc.
```
'Optional': 2563
'Any': 2402
'List': 2383
'Dict': 2150
'Tuple': 1592
'Union': 1269
'Callable': 1058
'Iterable': 609
'Set': 580
'cast': 505
'Sequence': 465
'Type': 438
'Iterator': 385
'TYPE_CHECKING': 357
'TypeVar': 302
'Mapping': 301
'Generator': 194
'NamedTuple': 138
'Text': 127
'IO': 120
'Awaitable': 116
...
```

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42102>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to