Skip to content

Descriptor Support on Official builds? #3644

Closed
@cefn

Description

@cefn

I note in https://github.com/micropython/micropython/wiki/Differences

simplified support for descriptors is now implemented, as an opt-in feature

I have been trying to port some CircuitPython libraries to run on Micropython, and for example adafruit_register relies on descriptors to tersely define values dynamically populated from I2C register reads.

My guess is that future Adafruit driver development is going down this track, so being able to run unmodified CircuitPython libraries might rely on descriptors or gnarly monkey-patching hacks to work around the absence of descriptors.

I found the build flag MICROPY_PY_DESCRIPTORS

Is it likely to be activated on e.g. Pyboard, ESP8266, ESP32 official builds soon?

Currently I have this on MicroPython v1.9.3 on 2017-11-01; PYBv1.1 with STM32F405RG following https://github.com/micropython/micropython/blob/da34b6ef452514170e8ce1d1819070a920c2568e/tests/basics/class_descriptor.py as expected if the support wasn't turned on...

paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== 
=== class Descriptor:
===     def __get__(self, obj, cls):
===         print('get')
===         print(type(obj) is Main)
===         print(cls is Main)
===         return 'result'
=== 
===     def __set__(self, obj, val):
===         print('set')
===         print(type(obj) is Main)
===         print(val)
=== 
===     def __delete__(self, obj):
===         print('delete')
===         print(type(obj) is Main)
=== 
=== class Main:
===     Forward = Descriptor()
>>> m = Main()
>>> m.Forward
<Descriptor object at 200032a0>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions