Skip to content

[GR-77645] Avoid temporary strings in specific APIs.#1035

Closed
graalvmbot wants to merge 4 commits into
masterfrom
fa/GR-77645/avoid_temp_attr_string
Closed

[GR-77645] Avoid temporary strings in specific APIs.#1035
graalvmbot wants to merge 4 commits into
masterfrom
fa/GR-77645/avoid_temp_attr_string

Conversation

@graalvmbot

Copy link
Copy Markdown
Collaborator

Some Python API function have a *String variant (e.g. PyObject_GetItemString) which takes a C string. Those usually create unicode object using PyObject_FromString which 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)AttrString where we only upcall if the receiver is managed.

Overview

  • PyObject_(Get|Set)AttrString Intrinsified for managed objects because staying in native for native receiver types is beneficial.
  • PyUnicode_InternFromString Fully 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_ModuleGetAttrString Fully intrinsified because module objects are usually managed.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 22, 2026
@graalvmbot graalvmbot closed this Jul 22, 2026
@graalvmbot
graalvmbot deleted the fa/GR-77645/avoid_temp_attr_string branch July 22, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants