Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
gh-91603: Speed up
UnionType
instantiation #91865New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-91603: Speed up
UnionType
instantiation #91865Changes from all commits
1d5de83
ac2b3a0
b8f9eae
d3dba88
3ac3013
7e87ef0
fde9507
bc348c9
fbc7934
4321116
f1e06da
70d9d30
e928a6c
8c3e307
97b2944
6b8e2e7
eb784c4
c82eca6
0cef035
c361b10
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need this logic for the callsite in
union_getitem
.Consider this case:
If I'm reading your code correctly, it would no longer deduplicate the two members. It would be good to also add a test case based on this example.
We should probably put the deduping logic directly in
union_getitem
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JelleZijlstra Actually, we don't need it, as far as such case already handled by tests:
cpython/Lib/test/test_types.py
Line 823 in 1cd8c29
That's because after parameter substitution new
UnionType
is recreated by reducingnewargs
usingbitwise or
operator:cpython/Objects/unionobject.c
Lines 380 to 388 in 1cd8c29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch! That seems a bit inefficient too, but we don't need to fix that in this PR; in any case it's probably a less performance-critical path.