Skip to content

py/objtype: Make mp_obj_new_type a static function. #17884

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

Merged

Conversation

dpgeorge
Copy link
Member

Summary

It's only used once, in the same file it's defined, and making it static reduces code size.

Along with this, the associated example code comment in ports/unix/main.c has been removed.

Testing

CI will test this.

Trade-offs and Alternatives

This removes the public mp_obj_new_type() API function. But, I doubt that's ever used (@dlech?) and it's more important to optimise code size rather than make this a public facing function.

(If it's really needed, it can be added as a static-inline wrapper.)

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Aug 11, 2025
Copy link

Code size report:

   bare-arm:   -16 -0.028% 
minimal x86:   -42 -0.022% 
   unix x64:   -40 -0.005% standard
      stm32:   -16 -0.004% PYBV10
     mimxrt:   -16 -0.004% TEENSY40
        rp2:   -16 -0.002% RPI_PICO_W
       samd:    -8 -0.003% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:   -11 -0.002% VIRT_RV32

Copy link
Contributor

@dlech dlech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we're not using it.

It's only used once, in the same file it's defined, and making it static
reduces code size.

Along with this, the associated example code comment in `ports/unix/main.c`
has been removed.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the py-objtype-make-new-type-function-static branch from 12f43d0 to 40cc4e4 Compare August 15, 2025 01:45
@dpgeorge dpgeorge merged commit 40cc4e4 into micropython:master Aug 15, 2025
69 of 70 checks passed
@dpgeorge dpgeorge deleted the py-objtype-make-new-type-function-static branch August 15, 2025 01:48
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (3efbd72) to head (40cc4e4).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17884   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22297    22297           
=======================================
  Hits        21938    21938           
  Misses        359      359           

☔ 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.

3 participants