A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-May/024057.html below:

[Python-Dev] Oberver Pattern

[Python-Dev] Oberver Patternholger krekel pyth@devel.trillke.net
Fri, 10 May 2002 20:39:48 +0200
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