Message380850
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:08 | Dominik V. | set | recipients:
+ Dominik V., gvanrossum, docs@python, levkivskyi, kj |
2020-11-12 21:25:08 | Dominik V. | set | messageid: <1605216308.12.0.983455697419.issue42317@roundup.psfhosted.org> |
2020-11-12 21:25:08 | Dominik V. | link | issue42317 messages |
2020-11-12 21:25:08 | Dominik V. | create | |
|