Currently we have
class A(Generic[T]): x = None A[int].x = 1 A[str].x = 'a' print(A[int].x) # prints 1 print(A[int]().x) # prints None, since type is erased on instantiation
@JukkaL argues and I agree with him, that this looks wrong. Conceptually, there should be only one runtime class. I think we can implement this without loosing the current runtime generic information by tweaking descriptor __dict__
of GenericMeta
, so that all assignments and look-ups on subscripted class objects like A[int]
will be transferred to the original class object A
.
@gvanrossum What do you think?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4