#19715·micropython

Store ROM qstr strings in a blob with 16-bit offsets

Author: dhalbertCreated Sep 17, 2026Updated Sep 17, 2026
Labelsenhancement

Description

CircuitPython has been on a quest to reduce firmware size, as we have a number of board builds that are close to full. I had Claude Fable look for opportunities. Some are already implemented but I did not know about them, like ulab NDARRAY_BINARY_USES_FUNCTION_POINTER, which saves about 4.5 kB. (https://github.com/adafruit/circuitpython/pull/11403) at the cost of performance.

However, another idea which came up (https://github.com/adafruit/circuitpython/issues/5276) was to store the compile-time qstr pool as a blob of concatenated strings and use an offsets table into it. The strings could be null-terminated, or could keep their length fields. These are the A and B alternatives in https://github.com/adafruit/circuitpython/issues/5276#issuecomment-5685157957.

A was implemented in https://github.com/adafruit/circuitpython/pull/11407.

We could submit an upstream PR but you may want to look at this yourselves as well.

Code Size

The size savings on even tiny builds is noticeable: Adafruit Trinket M0, a max-192kB build, saved 1.3 kB. A 512 kB build saved 3.4 kB, etc.

Implementation

I hope the MicroPython maintainers or community will implement this feature

Code of Conduct

Yes, I agree