Description
A typical read-only property object in shared-bindings
looks like this:
const mp_obj_property_t keypad_keys_num_keys_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&keypad_keys_get_num_keys_obj, // getter
MP_ROM_NONE, // setter
MP_ROM_NONE}, // deleter
};
There are a lot of these kinds of properties in the native modules, several hundred right now, so about 1200 bytes altogether for all modules. We could create a new mp_obj_getter_only_property_t
that has a proxy that only contains a getter, and corresponding mp_type_getter_only_property
, to get rid of the MP_ROM_NONE
s. That would save hundreds of bytes, though of course smaller builds have fewer properties.
Deleters are also very rare even in native modules, so we could add another type that is only getter/setter. I did not count up the savings for those yet.
Checking for mp_type_property
is done only in a few places, so those places would need extra code, but not a lot.