Skip to content

py/runtime: Reorder some binary ops so they don't require conditionals. #5273

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

Closed

Conversation

dpgeorge
Copy link
Member

runtime0.h is part of the MicroPython ABI (see #5083) so it's simpler if it's independent of config options, like MICROPY_PY_REVERSE_SPECIAL_METHODS.

What's effectively done here is just move MP_BINARY_OP_DIVMOD and MP_BINARY_OP_CONTAINS up in the enum, then remove the #if MICROPY_PY_REVERSE_SPECIAL_METHODS conditional.

Without this change .mpy files would need to have a feature flag for MICROPY_PY_REVERSE_SPECIAL_METHODS (when using #5083).

This commit has no effect when MICROPY_PY_REVERSE_SPECIAL_METHODS is disabled. With this option enabled it reduces code size by about 60 bytes.

runtime0.h is part of the MicroPython ABI so it's simpler if it's
independent of config options, like MICROPY_PY_REVERSE_SPECIAL_METHODS.

This commit has no effect when MICROPY_PY_REVERSE_SPECIAL_METHODS is
disabled.  With this option enabled it reduces code size by about 60 bytes.
@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Oct 29, 2019
@dpgeorge
Copy link
Member Author

Merged in 323d478

@dpgeorge dpgeorge closed this Oct 29, 2019
@dpgeorge dpgeorge deleted the py-shift-unary-binary-ops-v2 branch October 29, 2019 12:16
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant