You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
json: make "memo" dict local to scan_once call #111928
The Modules/_json.c parser is mostly stateless (or the state is immutable). The one exception is the "memo" dictionary, which is used to avoid duplicate PyUnicodeObject instances for the same JSON C strings.
We should move the creation and destruction of the memo dict to the invocation of scan_once instead of having it as part of the module state. This will avoid contention on the dictionary locks in --disable-gil builds if multiple threads are concurrently parsing JSON strings.
I just took a look at the example modification, and run the test on it locally and it succeded. I think there is no more works to do, so just cherry-picked it and made a PR.
If anyone think there need some improves, I want to investigate on it.
Activity
aisk commentedon Nov 12, 2023
I just took a look at the example modification, and run the test on it locally and it succeded. I think there is no more works to do, so just cherry-picked it and made a PR.
If anyone think there need some improves, I want to investigate on it.
gh-111928: make "memo" dict local to scan_once call (gh-112005)
colesbury commentedon Nov 13, 2023
Thanks @aisk!
pythongh-111928: make "memo" dict local to scan_once call (pythongh-1…
pythongh-111928: make "memo" dict local to scan_once call (pythongh-1…