Skip to content

bpo-44652: Preserve natural order of args in the union type.#27185

Merged
serhiy-storchaka merged 2 commits intopython:mainfrom
serhiy-storchaka:union-args-order
Jul 16, 2021
Merged

bpo-44652: Preserve natural order of args in the union type.#27185
serhiy-storchaka merged 2 commits intopython:mainfrom
serhiy-storchaka:union-args-order

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka commented Jul 16, 2021

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one comment below.

Comment thread Lib/test/test_types.py Outdated
check((str | int) | (int | list), (str, int, list))
check((str | int) | typing.Union[int, list], (str, int, list))
check(typing.Union[str, int] | (int | list), (str, int, list))
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I forgot to remove it.

Comment thread Objects/unionobject.c
PyObject* i_element = PyTuple_GET_ITEM(args, i);
for (Py_ssize_t j = i + 1; j < arg_length; j++) {
PyObject* j_element = PyTuple_GET_ITEM(args, j);
for (Py_ssize_t j = 0; j < added_items; j++) {
Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner Jul 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this should be faster too (for a small number of unique members :).

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG. Windows azure pipelines test_asyncio is failing which is unrelated.

@serhiy-storchaka serhiy-storchaka merged commit 0cd2d51 into python:main Jul 16, 2021
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Copy Markdown
Contributor

Sorry @serhiy-storchaka, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 0cd2d51aadcd2a0c0739a5df0a6235d64f35619e 3.10

@serhiy-storchaka serhiy-storchaka deleted the union-args-order branch July 16, 2021 13:11
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Jul 16, 2021
@bedevere-bot
Copy link
Copy Markdown

GH-27190 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 16, 2021
miss-islington pushed a commit that referenced this pull request Jul 16, 2021
…H-27185) (GH-27190)

(cherry picked from commit 0cd2d51)

Automerge-Triggered-By: GH:ambv
@serhiy-storchaka serhiy-storchaka removed their assignment Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants