-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[mypyc] feat: extend get_expr_length to work with RTuple and TupleType [2/4]
#19929
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
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
get_expr_length to work with RTuple and TupleType
|
If we merge #19931 first, this PR will be reflected in a change to its IR test data |
get_expr_length to work with RTuple and TupleTypeget_expr_length to work with RTuple and TupleType [2/4]
mypyc/irbuild/for_helpers.py
Outdated
| rtype = builder.node_type(expr) | ||
| if isinstance(rtype, RTuple): | ||
| return len(rtype.types) | ||
| proper_type = get_proper_type(builder.types[expr]) |
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.
Do we need this or will the check above it catch every case?
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.
This check is redundant. If this would be required for some unexpected reason, the issue should be fixed in node_type instead of here, since it would likely affect other things as well. Can you remove the second check?
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.
Removed
| r4 = box(int, r1) | ||
| r5 = box(int, r2) | ||
| r6 = box(int, r3) | ||
| r7 = PyTuple_Pack(3, r4, r5, r6) |
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.
Nice, the new IR is much more efficient!
This PR extends
get_expr_lengthto work with type information from RTuple and TupleType classesAll of the
get_expr_lengthPRs are entirely independent and can be reviewed/merged in any order.