Raymond Hettinger <raymond.hettin...@gmail.com> 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 way is more flexible in that it allows you to cache the unicode object for future use (something you're going to want to do if you care about performance). The latter way also lets you intern the string as well. FWIW, if it is only your own code, it is trivially easy to write your own helper function if that is what you needed for a single porting project. IMO, unnecessarily adding to many variants of the same function just makes the API harder to learn (see all the ObjectCall variants for example) and makes the code harder for us to maintain. ISTM most of the concrete APIs are deliberately sparse, so adding this variant would be a change in the philosophy of the C-API. Also, we mostly want people to use the abstract API unless they know for sure that a target dictionary is an exact dict (this has been an outstanding problem for OrderedDicts for example). ---------- nosy: +rhettinger _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35460> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com