-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] feat: true_dict_rprimitive for optimized dict fastpath usage #19499
New 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
Open
BobTheBuidler
wants to merge
43
commits into
python:master
Choose a base branch
from
BobTheBuidler:truedictprimitive
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
009c387
feat: true dict rprimitive
BobTheBuidler af7cf9d
fix: ordered dict
BobTheBuidler a075a3f
fix: mypy errs
BobTheBuidler abc0eb3
fix: mypy errs
BobTheBuidler 94ec27c
fix: mypy errs
BobTheBuidler 4eb3611
fix: mypy errs
BobTheBuidler cd8af87
feat: use true_dict_rprimitive for builtins.dict
BobTheBuidler 61db533
fix: mypy errs
BobTheBuidler 990b836
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6543e4f
fix: mypy errs
BobTheBuidler 89c4879
fix: clear ers never
BobTheBuidler efc9401
fix: err kind
BobTheBuidler c08f8b5
fix: err kind
BobTheBuidler b49e66d
fix: err kind
BobTheBuidler ee47b94
chore: rename true dict to exact dict
BobTheBuidler 4251e8b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a1f7f4f
chore: rename true_dict ops to exact_dict
BobTheBuidler 08674f7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5211d0b
Update mapper.py
BobTheBuidler c8bd207
update ir
BobTheBuidler f82b681
update ir
BobTheBuidler ee04ff4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 58c3b0e
update ir
BobTheBuidler 6093dd9
Update ll_builder.py
BobTheBuidler 05e1335
Update misc_ops.py
BobTheBuidler 64827cc
Update dict_ops.py
BobTheBuidler 6fb71fe
Update dict_ops.py
BobTheBuidler cf95f9f
Update rt_subtype.py
BobTheBuidler f837d1b
Update subtype.py
BobTheBuidler b97e823
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9299293
Update subtype.py
BobTheBuidler c2b6787
Update dict_ops.py
BobTheBuidler d7029ac
Update dict_ops.py
BobTheBuidler 66f57e6
Update dict_ops.py
BobTheBuidler c8e1901
Update dict_ops.py
BobTheBuidler 0a376c6
Update dict_ops.py
BobTheBuidler 0604390
Update ircheck.py
BobTheBuidler 90e75a5
update it
BobTheBuidler e86124d
update it
BobTheBuidler f01d87f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 77ac6bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 92598af
fix: ir
BobTheBuidler 677994d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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 could generalize this to other types by adding an
is_exact
attribute toRPrimitive
. Not sure whether it's worth it though --dict
is likely the one that will likely benefit the most from this.Uh oh!
There was an error while loading. Please reload this page.
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.
So when I was setting this up originally, I noticed that
dict
is unique in that we specialize operations on subclasses by considering all of them instances of dict_rprimitive. We don't currently do that for subclasses of other primitive types, but with the addition of this flag we easily could.I think that reason alone might make it worthwhile. Then we can support faster ops for cases like the first class in the below example, without breaking the second class in the example.
Example with
str.lower
: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.
I'm thinking a few steps ahead here of course, but the is_exact flag would be a critical first step
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.
@JukkaL before I start thinking on how to implement this attribute (it will involve a decent amount of refactoring for this PR) are there any specs/requirements you want me to keep in mind?
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.
It's probably better to add add the generalization later on, after we understand the different use cases better. We can add the generalization before we start adding other exact types (and this could be much later). It's not even clear how helpful other exact types would be -- maybe exact list and tuple types could be useful.