Skip to content

unicode: make _PyUnicode_FromId thread-safe in --disable-gil builds #111971

Closed
@colesbury

Description

@colesbury

Feature or enhancement

The _PyUnicode_FromId(_Py_Identifier *id) function gets a Python str object (i.e., a PyUnicodeObject) from a static C string. Subsequent calls to _PyUnicode_FromId() return the same object. The initialization is not currently thread-safe without the GIL.

Mostly for my own reference, here is the implementation from nogil-3.12: colesbury/nogil-3.12@6540bf3e6a. We will want to do things a bit differently in CPython 3.13.

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions