Raymond Hettinger wrote: > I would like to know what you all think about formalizing an observer > protocol for python objects. > > A possible implementation would add Py_TPFLAGS_OBSERVABLE and a slot, > tp_observer, with a function, PyObject_GenericAttach which registers a > callable to be notified when the object updates. > > Another approach would be to keep a single registry list with access > functions: attach(subject,observer), detach(subject,observer), and > notifyall(subject). PyObject_HEAD would have a field, int being_observed=0. > The attach() function sets being_observed. Any code affecting object state > is obliged to call PyObject_NOTIFY, a macro that checks being_observed and, > if set, calls notifyall(subject). doesn't "Any code affecting object state" include an awful lot of places? holger
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4