Skip to content

mpprint: Rework integer vararg handling. #17618

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 2 commits into from

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Jul 5, 2025

Summary

While working on format string errors in mp_printf (#17556) I experimented with adding support for %llx printing to mp_printf. In doing so, I re-organized mp_printf to increase the commonality of the various number printing possibilities.

When CI on 17556 turned up with a substantial size savings, it made me want to check if this change alone was the cause of the size savings. If so, and if the change is right, it might be worth taking independently of 17556.

Testing

I added new test cases to the unix coverage build and ran the tests locally. However, because the controls to enable/disable support for %l and %ll are different now, this really does need testing that is sure to cover all the cases and I'm not sure I've achieved that.

Trade-offs and Alternatives

In the current iteration of 17556, I am not actually using the llx format, so if this is not actually the source of the size savings reported there, then there's little reason to take it.

The changes to add MP_OBJ_FROM_PTR I think are "right" but they're incidental to this PR and should probably be rebased out. I briefly tried to enable the extra coverage code in the nanbox build and the build errored at these sites. Some other changes to the coverage tests were broken out to #17619

Copy link

github-actions bot commented Jul 5, 2025

Code size report:

   bare-arm:   -32 -0.056% 
minimal x86:  -355 -0.189% 
   unix x64:  -296 -0.035% standard
      stm32:   -40 -0.010% PYBV10
     mimxrt:   -56 -0.015% TEENSY40
        rp2:   -72 -0.008% RPI_PICO_W
       samd:   -40 -0.015% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:   -76 -0.017% VIRT_RV32

Copy link

codecov bot commented Jul 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.44%. Comparing base (5e9189d) to head (15e7c66).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17618   +/-   ##
=======================================
  Coverage   98.44%   98.44%           
=======================================
  Files         171      171           
  Lines       22204    22208    +4     
=======================================
+ Hits        21859    21863    +4     
  Misses        345      345           

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

@jepler jepler force-pushed the mpprint-reorg-llx branch 3 times, most recently from 1a0bc40 to 7829c6e Compare July 5, 2025 19:41
@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Jul 5, 2025
@dpgeorge
Copy link
Member

dpgeorge commented Jul 5, 2025

Wow! Nice code savings.

@dpgeorge dpgeorge added this to the release-1.26.0 milestone Jul 5, 2025
@dpgeorge
Copy link
Member

I tested this locally on PYBV10 using ./run-tests.py -t a0. Nothing fails.

@jepler
Copy link
Contributor Author

jepler commented Jul 15, 2025

Thanks! It may be a few days before I can implement your review suggestions.

jepler added 2 commits July 15, 2025 21:29
This adds support for %llx (needed by XINT_FMT for printing cell
objects) and incidentally support for capitalized output of %P.

Signed-off-by: Jeff Epler <jepler@gmail.com>
Test l and ll sized objects. When the platform's `mp_int_t`
is not 64 bits, dummy values are printed instead so the test
result can match across all platforms.

Ensure hex test values have a letter so 'x' vs 'X' is tested.

Test p and P pointer printing.

Signed-off-by: Jeff Epler <jepler@gmail.com>
@jepler jepler force-pushed the mpprint-reorg-llx branch from 7829c6e to 15e7c66 Compare July 15, 2025 20:29
@jepler jepler requested a review from dpgeorge July 15, 2025 20:29
@jepler
Copy link
Contributor Author

jepler commented Jul 15, 2025

Updated.

@dpgeorge
Copy link
Member

Rebased and merged in 0a4f9ec and 628d53d

@dpgeorge dpgeorge closed this Jul 16, 2025
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy