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>
This commit is contained in:
committed by
Damien George
parent
165388e4eb
commit
3c6127dfcf
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user