Skip to content

py/smallint: Introduce MP_SMALL_INT_BITS macro. #8443

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
wants to merge 1 commit into from

Conversation

dlech
Copy link
Contributor

@dlech dlech commented Mar 24, 2022

This adds a new MP_SMALL_INT_BITS macro that is a compile-time constant that contains the number of bits available in an
MP_SMALL_INT.

We can use this in place of the runtime function mp_small_int_bits().

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Mar 24, 2022
This adds a new `MP_SMALL_INT_BITS` macro that is a compile-time
constant that contains the number of bits available in an
`MP_SMALL_INT`.

We can use this in place of the runtime function `mp_small_int_bits()`.

Signed-off-by: David Lechner <david@pybricks.com>
@dlech dlech force-pushed the mp-small-int-bits branch from 26441ad to 11aafbe Compare March 24, 2022 17:33
@dpgeorge
Copy link
Member

Thanks, merged in 768879f

Note: the compiler was actually optimising mp_small_int_bits() to a constant. But this macro is better and can be more easily used in multiple locations.

@dpgeorge dpgeorge closed this Mar 25, 2022
@dlech
Copy link
Contributor Author

dlech commented Mar 25, 2022

the compiler was actually optimising mp_small_int_bits() to a constant.

👍 I was wondering why the code size diff was 0.

@dlech dlech deleted the mp-small-int-bits branch March 25, 2022 01:30
tannewt added a commit to tannewt/circuitpython that referenced this pull request Feb 16, 2024
Doing it implicitly can lead to mistaken socket leaks and reuse.
It now matches CPython.

Fixes micropython#8443
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.

2 participants