gh-146041: Avoid lock in sys.intern() for already interned strings#146072
gh-146041: Avoid lock in sys.intern() for already interned strings#146072colesbury merged 4 commits intopython:mainfrom
Conversation
|
@encukou, please let me know if you'd like me to do this differently. I've removed the assertion about unicode state in |
| PyObject *r; | ||
| int res = PyDict_GetItemRef(interned, s, &r); | ||
| if (res < 0) { | ||
| PyErr_Clear(); |
There was a problem hiding this comment.
Clearing the error here feels a little weird to me, but it's consistent with the rest of the function.
|
🤖 New build scheduled with the buildbot fleet by @colesbury for commit 6e59598 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F146072%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
|
Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @colesbury, I could not cleanly backport this to |
…ed strings (pythongh-146072) Fix free-threading scaling bottleneck in sys.intern and `PyObject_SetAttr` by avoiding the interpreter-wide lock when the string is already interned and immortalized. (cherry picked from commit 6009309) Co-authored-by: Sam Gross <colesbury@gmail.com>
|
GH-146390 is a backport of this pull request to the 3.14 branch. |
Fix free-threading scaling bottleneck in sys.intern and
PyObject_SetAttrby avoiding the interpreter-wide lock when the string is already interned and immortalized.sys.intern()#146041