Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jepler
Copy link
Contributor

@jepler jepler commented Nov 10, 2025

Summary

An identifier like MP_CONST_FLOAT_e introduces a floating point constant object. This is preferable to the previous method where, presumably, a human hand-created the constant values. It also facilitates introducing new floating point constant objects, assuming they can be written as literals (this is missed in ulab & circuitpython).

Testing

I locally built coverage, nanbox, and longlong. The CI may turn up additional mistakes.

  • mac build (python version)
  • windows build (doesn't know to build float_consts.h)
  • zepyhyr, cc3200: ditto
  • embed: doesn't know to copy float_consts.h

Trade-offs and Alternatives

The alternative of doing nothing is a powerful one, since nothing is broken. This was on my mind because there's a suggestion of making a new OBJ_REPR for 32 bit floats that avoids losing 2 precision bits by storing some floats "boxed" and others "unboxed", and furnished a way for me to learn a little bit about float representation.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (2762fe6) to head (122928d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #18396   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22294    22294           
=======================================
  Hits        21933    21933           
  Misses        361      361           

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

@github-actions
Copy link

github-actions bot commented Nov 10, 2025

Code size report:

Reference:  tests/serial_test.py: Allow up to 2 seconds between bytes. [2762fe6]
Comparison: core: Flexibly define float constant objects. [merge of 122928d]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Now, use of an identifier like `MP_CONST_FLOAT_e`
introduces a floating point constant object.

Signed-off-by: Jeff Epler <[email protected]>
@jepler
Copy link
Contributor Author

jepler commented Nov 12, 2025

The version in #18401 has diverged, closing this up.

@jepler jepler closed this Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant