[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public
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

bpo-37348: optimize decoding ASCII string #14283

Merged
merged 7 commits into from Jun 24, 2019

Conversation

Copy link
Member

methane commented Jun 21, 2019

Use _PyUnicode_Writer only after ascii_decode is failed.

https://bugs.python.org/issue37348

brettcannon added the performance Performance or resource usage label Jun 21, 2019
Objects/unicodeobject.c Outdated Show resolved Hide resolved
Copy link
Member Author

methane commented Jun 22, 2019

$ ./python -m pyperf timeit --compare-to=./python-master -s 'b=b"foo"' -- 'b.decode()'
python-master: ..................... 83.3 ns +- 1.2 ns
python: ..................... 72.4 ns +- 1.1 ns

Mean +- std dev: [python-master] 83.3 ns +- 1.2 ns -> [python] 72.4 ns +- 1.1 ns: 1.15x faster (-13%)

PyUnicode_FromString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");: about 38ns -> 28ns

methane merged commit 770847a into python:master Jun 24, 2019
methane deleted the ascii-fromstring branch Jun 24, 2019
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
`_PyUnicode_Writer` is a relatively complex structure.  Initializing it is significant overhead when decoding short ASCII string.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
`_PyUnicode_Writer` is a relatively complex structure.  Initializing it is significant overhead when decoding short ASCII string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants