This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients ronaldoussoren, scoder, serhiy.storchaka
Date 2019-02-10.14:42:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1549809770.18.0.440772751962.issue35460@roundup.psfhosted.org>
In-reply-to
Content
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 calculate its hash value, just to throw away all that right after the tiny time interval that it takes to look up the key in the dict. It is not something I would encourage anyone to do in code that has only the slightest excuse for being implemented in C. :)

Rather, I would propose to open up the ID-String API that CPython uses internally, so that user code can benefit from fast lookups of interned strings with pre-initialised hash values, without having to care about creating and cleaning up string constants themselves all the time.

(FWIW, Cython also generates interned string constants automatically, but does not currently use the ID-API, also because it does it for *all* its strings, not just those that resemble identifiers etc.)
History
Date User Action Args
2019-02-10 14:42:51scodersetrecipients: + scoder, ronaldoussoren, serhiy.storchaka
2019-02-10 14:42:50scodersetmessageid: <1549809770.18.0.440772751962.issue35460@roundup.psfhosted.org>
2019-02-10 14:42:50scoderlinkissue35460 messages
2019-02-10 14:42:49scodercreate