Skip to content

py/smallint: Introduce MP_SMALL_INT_BITS macro. - #8443

Closed
dlech wants to merge 1 commit into
micropython:masterfrom
dlech:mp-small-int-bits
Closed

py/smallint: Introduce MP_SMALL_INT_BITS macro.#8443
dlech wants to merge 1 commit into
micropython:masterfrom
dlech:mp-small-int-bits

Conversation

@dlech

@dlech dlech commented Mar 24, 2022

Copy link
Copy Markdown
Contributor

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
Comment thread py/smallint.h Outdated
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
Copy Markdown
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

dlech commented Mar 25, 2022

Copy link
Copy Markdown
Contributor Author

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
@codecov

codecov Bot commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.25%. Comparing base (66fe3d5) to head (11aafbe).
⚠️ Report is 5051 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8443      +/-   ##
==========================================
- Coverage   98.25%   98.25%   -0.01%     
==========================================
  Files         154      154              
  Lines       20284    20277       -7     
==========================================
- Hits        19931    19924       -7     
  Misses        353      353              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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