[Python-Dev] PyDict_SetItem hook
Ronald Oussoren
ronaldoussoren at mac.com
Tue Apr 7 17:10:01 CEST 2009
On 3 Apr, 2009, at 0:57, Guido van Rossum wrote:
>>
>
> The primary use case is some kind of trap on assignment. While this
> cannot cover all cases, most non-local variables are stored in dicts.
> List mutations are not in the same league, as use case.
I have a slightly different use-case than a debugger, although it
boils down to "some kind of trap on assignment": implementing Key-
Value Observing support for Python objects in PyObjC. "Key-Value
Observing" is a technique in Cocoa where you can get callbacks when a
property of an object changes and is something I cannot support for
plain python objects at the moment due to lack of a callback
mechanism. A full implementation would require hooks for mutation of
lists and sets as well.
The lack of mutation hooks is not a terrible problem for PyObjC, we
can always use Cocoa datastructures when using KVO, but it is
somewhat annoying that Cocoa datastructures leak into code that could
be pure python just because I want to use KVO.
Ronald
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2224 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090407/aff7279e/attachment-0001.bin>
More information about the Python-Dev
mailing list