-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Currently in python there exist descriptors with the __get__ and not the __set__ (nor __delete__). They are called "non-data descriptors" and are used to put a hook on get, but to allow users to replace the attribute entirely easily.
In certain cases the opposite could be interesting to have: a descriptor with hooks on __set__ but none on __get__ for fast access. However it would require some kind of a convention on the name where the actual value to return would reside, so not easy to propose a way to enter this information.
An alternative is simply to propose a "fast get" implementer method like this:
class MyDescriptor:
__get__ = native_read_attr('value') # <-- this mark would enable fast get
def __set__(self, obj, value):
...(hooks)
obj.value = valueSee also smarie/python-pyfields#18