[issue35460] Add PyDict_GetItemStringWithError

2019-02-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See also issue35459. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35460] Add PyDict_GetItemStringWithError

2019-02-11 Thread Ronald Oussoren
Ronald Oussoren added the comment: I can live without this API, I mostly filed this issue because there's an obvious hole in the API when you look at API description: SetItem, SetItemString, DelItem, DelItemString, GetItem, GetItemString, GetItemWithError, <>. Thanks for the explanations.

[issue35460] Add PyDict_GetItemStringWithError

2019-02-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 for expanding this API. As Serhiy pointed-out, PyDict_GetItemString() is an old API kept just for backward compatibility. For your use case, it is easy to call PyUnicode_FromString(key) and then follow-up with PyDict_GetItemWithError(). The latter w

[issue35460] Add PyDict_GetItemStringWithError

2019-02-10 Thread Ronald Oussoren
Ronald Oussoren added the comment: There are more reasons to implement in C than just speed ;-). In my code I have two usecases for using PyDict_GetItemString, both not in performance critical code 1) Look up a hardcoded name in a dictionary. These could be switched to the Id API if that we

[issue35460] Add PyDict_GetItemStringWithError

2019-02-10 Thread Stefan Behnel
Stefan Behnel added the comment: The overhead of calling PyErr_Occurred() is definitely negligible in something as involved as PyDict_GetItemStringWithError(), where a mere key lookup first has to fire up the string decoder on a C character buffer to create a new string object and then calcu

[issue35460] Add PyDict_GetItemStringWithError

2019-02-10 Thread Ronald Oussoren
Ronald Oussoren added the comment: Adding PyDict_GetItemStringWithError makes is possible to migrate existing code to a design that does not ignore errors. I have a significant number of calls to PyDict_GetItemString that cannot be switch toed PyDict_GetItem without increasing the number of

[issue35460] Add PyDict_GetItemStringWithError

2018-12-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 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 Py

[issue35460] Add PyDict_GetItemStringWithError

2018-12-11 Thread Ronald Oussoren
New submission from Ronald Oussoren : PyDict_GetItemWithError is a variant of PyDict_GetItem that doesn't swallow unrelated exceptions. While converting a project to use this API I noticed that there is similar variant of PyDict_GetItemString. It would be nice to have PyDict_GetItemStringWit