-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Using the public PyUnicodeWriter C API made the json module slower #133968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See also #133186. |
Don't call PyObject_Str() if the input type is str.
Don't call PyObject_Str() if the input type is str.
Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII().
Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII().
Could you try overoptimizing
|
I don't know how to guarantee that.
Why do you want to limit the size to sizeof(size_t)? Which kind of optimization are you thinking of? find_first_nonascii() already takes care of the different cases with different optimizations. ascii_decode() is already highly optimized. |
Indeed it is! After playing around a bit, I could only optimize short-ASCII-strings at the expense of other strings, or a lot of code duplication.
For the record: |
Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII(). Unrelated change to please the linter: remove an unused import in test_ctypes. Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…3973) Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII(). Unrelated change to please the linter: remove an unused import in test_ctypes. Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> (cherry picked from commit f49a07b)
…#134974) gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973) Replace most PyUnicodeWriter_WriteUTF8() calls with PyUnicodeWriter_WriteASCII(). (cherry picked from commit f49a07b) Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
The function was added to Python 3.14.
The function was added to Python 3.14.
I close the issue. Multiple changes optimized the If someone has more optimization ideas, I suggest opening a new issue. |
Uh oh!
There was an error while loading. Please reload this page.
I modified the json module to replace the private _PyUnicodeWriter C API with the public PyUnicodeWriter C API:
Problem: it made the json module slower. Let's investigate what's going on.
Linked PRs
The text was updated successfully, but these errors were encountered: