-
Notifications
You must be signed in to change notification settings - Fork 259
Is it still necessary to prohibit generics at runtime? #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
However mypy still prohibits it. I'd much rather remove this from mypy and leave it in the PEP than the other way around. ;-) |
This was referenced Oct 21, 2016
gvanrossum
pushed a commit
to python/mypy
that referenced
this issue
Oct 24, 2016
As discussed in python/typing#303 generics in ``typing.py`` are now cached and are therefore much faster at runtime than before. Here I propose (and it looks like Guido is not against this) to allow generic types as runtime expressions.
gvanrossum
pushed a commit
to python/peps
that referenced
this issue
Oct 24, 2016
Fixes python/typing#303. See also python/mypy#2302 (which removes the restriction from mypy). As a motivation, in Python one always can substitute expressions, so that if ``IntNode = Node[int]; IntNode()`` works, then it is reasonable to also allow ``Node[int]``, but say that the first way is preferred.
rowillia
pushed a commit
to rowillia/mypy
that referenced
this issue
Oct 24, 2016
As discussed in python/typing#303 generics in ``typing.py`` are now cached and are therefore much faster at runtime than before. Here I propose (and it looks like Guido is not against this) to allow generic types as runtime expressions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a paragraph in PEP 484:
However,
__getitem__
is cached for generics now and this leads to significant speedup (Guido reported up to 300x speedup in extreme cases). I think the above restriction is not necessary anymore and could be removed from the PEP.The text was updated successfully, but these errors were encountered: