[Python-Dev] PyDict_Get/SetItem and dict subclasses (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sun Nov 6 17:39:02 CET 2011
- Previous message: [Python-Dev] PyDict_Get/SetItem and dict subclasses
- Next message: [Python-Dev] PyDict_Get/SetItem and dict subclasses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le 05/11/2011 17:34, Éric Araujo a écrit :
Hi Victor,
PyDictGetItem() and PyDictSetItem() don't call getitem and setitem for dict subclasses. Is there a reason for that? http://bugs.python.org/issue10977 “Currently, the concrete object C API bypasses any methods defined on subclasses of builtin types.”
I think that's the correct behaviour. If you expect to get an arbitrary mapping, just use the abstract API. You should use PyDict_GetItem when you know the object is exactly a dict (generally because you have created it yourself, or you know at least where and how it was created).
Regards
Antoine.
- Previous message: [Python-Dev] PyDict_Get/SetItem and dict subclasses
- Next message: [Python-Dev] PyDict_Get/SetItem and dict subclasses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]