diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-02-15 16:09:04 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-10-30 11:10:02 +1100 |
commit | 64c79a54239d700ecb8d7f07b13388dc79f28993 (patch) | |
tree | fece80e668f1dfab1cd793d57cf9f994924f1c94 /py/persistentcode.c | |
parent | e910533012b7298f5c11622d501878c678dbf45e (diff) |
py/qstr: Add support for sorted qstr pools.
This provides a significant performance boost for qstr_find_strn, which is
called a lot during parsing and loading of .mpy files, as well as interning
of string objects (which happens in most string methods that return new
strings).
Also adds comments to explain the "static" qstrs. These are part of the
.mpy ABI and avoid needing to duplicate string data for QSTRs known to
already be in the firmware. The static pool isn't currently sorted, but in
the future we could either split the static pool into the sorted regions,
or in the next .mpy version just sort them.
Based on initial work done by @amirgon in #6896.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/persistentcode.c')
-rw-r--r-- | py/persistentcode.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/persistentcode.c b/py/persistentcode.c index 0feb93bdb..df1003bab 100644 --- a/py/persistentcode.c +++ b/py/persistentcode.c @@ -40,6 +40,11 @@ #include "py/smallint.h" +// makeqstrdata.py has a fixed list of qstrs at the start that we can assume +// are available with know indices on all MicroPython implementations, and +// avoid needing to duplicate the string data in the .mpy file. This is the +// last one in that list (anything with a qstr less than or equal to this is +// assumed to be in the list). #define QSTR_LAST_STATIC MP_QSTR_zip #if MICROPY_DYNAMIC_COMPILER |