Message331623
PyDict_GetItemString() is an old API from times when dicts could contain only string keys. It is not necessary part of the C API and can be replaced with PyDict_GetItem() in new code. It was kept only as a convenient function.
In issue35459 many uses of PyDict_GetItemString() were replaced with PyDict_GetItemWithError() and private _PyDict_GetItemIdWithError(). Only 4 occurrences were replaced with newly added private _PyDict_GetItemStringWithError(). And they could use PyDict_GetItem(). So there are not much use cases for PyDict_GetItemStringWithError().
Before adding PyDict_GetItemStringWithError() we could consider alternatives.
*WithError() functions require calling PyErr_Occurred() to distinguish the error case from the "not found" case. This adds an overhead which can be not small in performance critical code. It would be better if the API function returned a three-state value: "found", "not found" and "error". See for example _PyObject_LookupAttr(). I am not sure this is the best design. |
|
Date |
User |
Action |
Args |
2018-12-11 13:48:48 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ronaldoussoren |
2018-12-11 13:48:48 | serhiy.storchaka | set | messageid: <1544536128.55.0.788709270274.issue35460@psf.upfronthosting.co.za> |
2018-12-11 13:48:48 | serhiy.storchaka | link | issue35460 messages |
2018-12-11 13:48:48 | serhiy.storchaka | create | |
|