-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-131798: Add MATCH_SEQUENCE/MAPPING to the JIT optimizer
#148124
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2071,6 +2071,28 @@ dummy_func(void) { | |||||||||||||||||||||||||||||||||
| n = names; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| op(_MATCH_MAPPING, (subject -- subject, res)) { | ||||||||||||||||||||||||||||||||||
| if (sym_has_type(subject)) { | ||||||||||||||||||||||||||||||||||
| PyTypeObject *type = sym_get_type(subject); | ||||||||||||||||||||||||||||||||||
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | ||||||||||||||||||||||||||||||||||
| res = match ? sym_new_const(ctx, Py_True) : sym_new_const(ctx, Py_False); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||||||||||||
| res = sym_new_type(ctx, &PyBool_Type); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| if (sym_has_type(subject)) { | |
| PyTypeObject *type = sym_get_type(subject); | |
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | |
| res = match ? sym_new_const(ctx, Py_True) : sym_new_const(ctx, Py_False); | |
| } | |
| else { | |
| res = sym_new_type(ctx, &PyBool_Type); | |
| } | |
| PyTypeObject *type = sym_get_type(subject); | |
| if (type != NULL) { | |
| int match = type->tp_flags & Py_TPFLAGS_MAPPING; | |
| res = sym_new_const(ctx, match ? Py_True : Py_False); | |
| } | |
| else { | |
| res = sym_new_type(ctx, &PyBool_Type); | |
| } |
Outdated
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.
Ditto
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.
Done!
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 also wonder if this logic will be broken by abc.register.
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.
Hmm I'm not too sure either. I'll try to see if I can find out more