diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2021-07-15 15:04:40 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-19 19:06:09 +1000 |
commit | 3ac8b5851e5f4dade465d52b91ed2ccc17851263 (patch) | |
tree | 15132801d2f3ffcb54baf1eec185aa5e86e9bde2 /py/objstringio.c | |
parent | a52cd5b07d6d6e2502fff2bbfb9e5b96562452a4 (diff) | |
download | micropython-3ac8b5851e5f4dade465d52b91ed2ccc17851263.tar.gz micropython-3ac8b5851e5f4dade465d52b91ed2ccc17851263.zip |
py/obj: Add slot-index mp_obj_type_t representation.
The existings mp_obj_type_t uses a sparse representation for slots for the
capability methods of the type (eg print, make_new). This commit adds a
compact slot-index representation. The basic idea is that where the
mp_obj_type_t struct used to have 12 pointer fields, it now has 12 uint8_t
indices, and a variable-length array of pointers. So in the best case (no
fields used) it saves 12x4-12=36 bytes (on a 32-bit machine) and in the
common case (three fields used) it saves 9x4-12=24 bytes.
Overall with all associated changes, this slot-index representation reduces
code size by 1000 to 3000 bytes on bare-metal ports. Performance is
marginally better on a few tests (eg about 1% better on misc_pystone.py and
misc_raytrace.py on PYBv1.1), but overall marginally worse by a percent or
so.
See issue #7542 for further analysis and discussion.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/objstringio.c')
0 files changed, 0 insertions, 0 deletions