Guido van Rossum wrote: > I'm torn. While trying to implement this I came across some ugliness > in PyDict_GetItem() -- it would make sense if this also called > on_missing(), but it must return a value without incrementing its > refcount, and isn't supposed to raise exceptions -- so what to do if > on_missing() returns a value that's not inserted in the dict? I think there should be a guideline to use PyObject_GetItem/PyMapping_GetItemString "normally", i.e. in all cases where you would write d[k] in Python code. It should be considered a bug if PyDict_GetItem is used in a place that "should" invoke defaulting; IOW, the function should be reserved to really low-level cases (e.g. if it is known that the dict doesn't have any defaulting, e.g. the string interned dictionary). There should be a policy whether name-lookup invokes defaulting (i.e. __dict__ access); I think it should. This would cause __getattr__ to have no effect if the object's dictionary has a default factory (unless that raises a KeyError). Regards, Martin
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