On Mon, Apr 12, 2021 at 7:47 PM Paul Bryan email@example.com wrote:
In 3.9 this cost is paid once when a type is defined. However, in 3.10, it gets expensive, because when the string is evaluated by get_type_hints, its result is not stored/cached anywhere (repeated calls to get_type_hints results in repeated evaluation). As a workaround, I have code to "affix" the evaluated expression in __annotations__ value. PEP 649 would resolve this and eliminate the need for such a hack.
Why not submit a PR that adds caching to get_type_hints(), rather than promote a paradigm shift?