Skip to content

py: clean up use of mp_verbose_flag#19313

Open
dpgeorge wants to merge 2 commits into
micropython:masterfrom
dpgeorge:py-clean-up-mp-verbose-flag
Open

py: clean up use of mp_verbose_flag#19313
dpgeorge wants to merge 2 commits into
micropython:masterfrom
dpgeorge:py-clean-up-mp-verbose-flag

Conversation

@dpgeorge
Copy link
Copy Markdown
Member

@dpgeorge dpgeorge commented Jun 5, 2026

Summary

Remove unused mp_verbose_flag from mpy-cross. This variable does nothing in mpy-cross because:

  • MICROPY_DEBUG_PRINTERS is not enabled, so the relevant code in py/compile.c that uses mp_verbose_flag is unused.
  • Even if MICROPY_DEBUG_PRINTERS was enabled, nothing happens because mpy-cross has MP_PLAT_PRINT_STRN defined to do nothing.
  • MICROPY_PY_MICROPYTHON_MEM_INFO is not enabled.

So remove it. But keep the -v CLI option to not break existing uses of mpy-cross, and keep it compatible with the CLI options of the unix port. There is therefore no functional change.

And move mp_verbose_flag to MP_STATE_VM struct. This stray global variable doesn't really belong in py/emitglue.c because it's currently only used by py/compile.c. So move it to the state context struct alongside the related compiler settings.

Testing

  • tested that mpy-cross still accepts -v but does nothing
  • tested 0 through 4 -v arguments to unix standard and coverage builds and checked the behaviour was still the same

Generative AI

Not used.

dpgeorge added 2 commits June 5, 2026 16:46
This variable does nothing in mpy-cross because:
- `MICROPY_DEBUG_PRINTERS` is not enabled, so the relevant code in
  `py/compile.c` that uses `mp_verbose_flag` is unused.
- Even if `MICROPY_DEBUG_PRINTERS` was enabled, nothing happens because
  mpy-cross has `MP_PLAT_PRINT_STRN` defined to do nothing.
- `MICROPY_PY_MICROPYTHON_MEM_INFO` is not enabled.

So remove it.  But keep the `-v` CLI option to not break existing uses of
mpy-cross, and keep it compatible with the CLI options of the unix port.

Signed-off-by: Damien George <damien@micropython.org>
This stray global variable doesn't really belong in `py/emitglue.c` because
it's currently only used by `py/compile.c`.  So move it to the state
context struct alongside the related compiler settings.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Jun 5, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.47%. Comparing base (af38ee1) to head (a4bfad9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19313   +/-   ##
=======================================
  Coverage   98.47%   98.47%           
=======================================
  Files         176      176           
  Lines       22845    22846    +1     
=======================================
+ Hits        22497    22498    +1     
  Misses        348      348           

☔ View full report in Codecov by Harness.
📢 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
Copy Markdown

github-actions Bot commented Jun 5, 2026

Code size report:

Reference:  samd/mphalport: Run events at least once in mp_hal_delay_ms. [af38ee1]
Comparison: py/mpstate: Move mp_verbose_flag to MP_STATE_VM struct. [merge of a4bfad9]
  mpy-cross:    -8 -0.002% [incl -8(bss)]
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:   +48 +0.006% standard[incl +32(bss)]
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     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

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.

1 participant