Continuing from yesterday, when I was looking into the attribute __origin__, I found a PEP called PEP 560 --Core support for typing module and generic types. I arrived at. This PEP has been around since 3.7, so it's an implementation that already exists and can be touched.
Typing module performancetyping module__class_getitem__ and __mro_entries____class_getitem____Getitem__ for class objects__mro_entries____mro_entries__typing._GenericAlias__mro_entries__ ofList [int]returns list, so it behaves as a subclass of list at runtime.__orig_base__, and resolved inherited classes are stored in __base__typing._GenericAliastyping module.__origin__, which was a punch line that was a private attribute to realize __mro_entries__.__class_getitem__ well, it will be worth hacking.Recommended Posts