Author kornicameister
Recipients kornicameister
Date 2020-01-11.23:35:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1578785715.62.0.203170094807.issue39308@roundup.psfhosted.org>
In-reply-to
Content
Consider code (in attachment) that is being run on Python 3.9.
An expected output of such code ought to be:

(typing_extensions.Literal[1], typing_extensions.Literal[0]) (typing_extensions.Literal[True], typing_extensions.Literal[False])

However that's not the case. An output of the code, given that A is declared first, will be:

(typing.Literal[1], typing.Literal[0]) (typing.Literal[1], typing.Literal[0])

and if B is declared first we receive:

(typing.Literal[True], typing.Literal[False]) (typing.Literal[True], typing.Literal[False])

I believe a reason for that is having `bool` as subclass of `int` and consecutively having `typing._tp_cache` function that declares untyped cache. Indeed changing `cached = functools.lru_cache()(func)` to `cached = functools.lru_cache(typed=True)(func)` makes the linked code immune to A and B deceleration order.
History
Date User Action Args
2020-01-11 23:35:15kornicameistersetrecipients: + kornicameister
2020-01-11 23:35:15kornicameistersetmessageid: <1578785715.62.0.203170094807.issue39308@roundup.psfhosted.org>
2020-01-11 23:35:15kornicameisterlinkissue39308 messages
2020-01-11 23:35:15kornicameistercreate