diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2022-09-14 00:39:48 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-09-19 19:06:13 +1000 |
commit | 3c6127dfcfc63a2b48c31f751d1ae2c385874c8a (patch) | |
tree | 278e9b383b04a3ebe4fabc4379f6665760005038 /py/objnamedtuple.h | |
parent | 165388e4eb5db1207f4d839abe77d417d4c3f7c3 (diff) |
py/objnamedtuple: Optimise slot RAM usage for namedtuple.
Rather than reserving a full 12-slot mp_obj_type_t, reserve enough room for
seven and cast as necessary.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/objnamedtuple.h')
-rw-r--r-- | py/objnamedtuple.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index 9f23351d5..db4a3d87d 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -29,10 +29,9 @@ #include "py/objtuple.h" typedef struct _mp_obj_namedtuple_type_t { - // Must use the full-size version to avoid this being a variable sized member. - // This means that named tuples use slightly more RAM than necessary, but - // no worse than if we didn't have slots/split representation. - mp_obj_full_type_t base; + // This is a mp_obj_type_t with seven slots. + mp_obj_empty_type_t base; + void *slots[7]; size_t n_fields; qstr fields[]; } mp_obj_namedtuple_type_t; |