This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dominik V.
Recipients Dominik V., docs@python, gvanrossum, kj, levkivskyi
Date 2020-11-12.21:25:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Thinking more about it, I came to realize that it's not the Union that sits at the root of this behavior, but rather the caching performed by generic types in general. So if we consider

L1 = List[Union[int, str]]
L2 = List[Union[str, int]]

then `get_args(L1)[0] is get_args(L2)[0]` and so `get_args` has no influence on the order of arguments of the Union objects (they are already the same for L1 and L2).

So I think it would be more accurate to add the following sentence instead:

> If `X` is a generic type, the returned objects `(Y, Z, ...)` might not be identical to the ones used in the form `X[Y, Z, ...]` due to type caching.

Everything else follows from there (including flattening of nested Unions).
Date User Action Args
2020-11-12 21:25:08Dominik V.setrecipients: + Dominik V., gvanrossum, docs@python, levkivskyi, kj
2020-11-12 21:25:08Dominik V.setmessageid: <>
2020-11-12 21:25:08Dominik V.linkissue42317 messages
2020-11-12 21:25:08Dominik V.create