Changing runtime behavior of types.UnionType to respect order in equality and hashing

@guido suggested that we could preserve order by changing our typing cache to respect order. This way we don’t need backwards incompatible changes or writing a PEP. Users would be saved from a lot of trouble :).

@sobolevn seems to already be working on this in Make sure that typing cache differentiate `Union[int, str]` and `Union[str, int]` · Issue #103749 · python/cpython · GitHub.

I think this issue’s title is now defunct/outdated.

3 Likes