| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Don't call PyObject_Str() if the input type is str.
|
Microbenchmark: Mean +- std dev: [ref] 70.5 ns +- 1.1 ns -> [change] 58.3 ns +- 3.8 ns: 1.21x faster from _testcapi import PyUnicodeWriter
import pyperf
range_100 = range(100)
def bench_write_str():
writer = PyUnicodeWriter(0)
for _ in range_100:
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
writer.write_str("true")
runner = pyperf.Runner()
runner.bench_func('write_str', bench_write_str, inner_loops=1_000) |
Sorry, something went wrong.
|
JSON benchmark: #133832 (comment)
Encoding booleans is now up to 1.61x faster which is quite appealing! |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
Sorry, something went wrong.
|
GH-133971 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
|
When I wrote PyUnicodeWriter_WriteStr(), I skipped this fast path since PyObject_Str() already has a fast path. But it seems like adding one in PyUnicodeWriter_WriteStr() makes a big difference on microbenchmarks! |
Sorry, something went wrong.
…133969) Don't call PyObject_Str() if the input type is str.
…133969) Don't call PyObject_Str() if the input type is str.
| Back | FazBrowse Home | New Git URL |
Don't call PyObject_Str() if the input type is str.