You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
classMyDescriptor:
__get__=native_read_attr('value') # <-- this mark would enable fast getdef__set__(self, obj, value):
...(hooks)
obj.value=value
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:
See also smarie/python-pyfields#18
The text was updated successfully, but these errors were encountered: