[GR-77645] Avoid temporary strings in specific APIs.#1035
Closed
graalvmbot wants to merge 4 commits into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some Python API function have a
*Stringvariant (e.g.PyObject_GetItemString) which takes a C string. Those usually create unicode object usingPyObject_FromStringwhich is delegated to the more generic API and the unicode object is immediately decref'd after that.That's, ofc, bad for us because that may cause a lot of unnecessary work.
The idea is to intrinsify those APIs and so we hopefully avoid the to-native transformation for the unicode object.
However, for some operations, it may also be even better to stay in native if the receiver object is a native object. This is, in particular, the case for
PyObject_(Get|Set)AttrStringwhere we only upcall if the receiver is managed.Overview
PyObject_(Get|Set)AttrStringIntrinsified for managed objects because staying in native for native receiver types is beneficial.PyUnicode_InternFromStringFully intrinsified since interning is implemented in Java.PyDict_(Get|Set|Del)ItemString(WithError)Fully intrinsified because we previously created a temp string just to call fully intrinsified operation._PyImport_ModuleGetAttrStringFully intrinsified because module objects are usually managed.