Dominik V. <dominik.vilsmeier1...@gmail.com> added the comment:
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). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42317> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com