8000 Save space by removing slots from property proxies when possible · Issue #4899 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
Save space by removing slots from property proxies when possible #4899
Closed
@dhalbert

Description

@dhalbert

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_NONEs. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0