GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-37348: optimize decoding ASCII string by methane · Pull Request #14283 · python/cpython

Conversation

@methane

@methane methane commented Jun 21, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Use _PyUnicode_Writer only after ascii_decode is failed.

https://bugs.python.org/issue37348

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
methane added 2 commits June 21, 2019 19:08
@methane
Skip using _PyUnicodeWriter for simple ASCII string
dcd2219
@methane
code cleanup
40750a2
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jun 21, 2019
@bedevere-bot bedevere-bot added the awaiting core review label Jun 21, 2019
@methane
fix error handler writes after allocated
60be283
@methane methane mentioned this pull request Jun 21, 2019
bpo-37348: optimize decoding ASCII string #14291
Closed
@brettcannon brettcannon added the performance Performance or resource usage label Jun 21, 2019
vstinner
vstinner reviewed Jun 21, 2019
View reviewed changes
Comment thread Objects/unicodeobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

methane added 3 commits June 23, 2019 00:11
@methane
add _PyUnicodeWriter_InitWithBuffer function
0c5d9d4
@methane
fix indent
3d34e17
@methane
fix return type
7f5698d
@methane

methane commented Jun 22, 2019

Copy link
Copy Markdown
Member Author
$ ./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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@methane
add NEWS entry
24c7b2a
@methane
methane merged commit 770847a into python:master Jun 24, 2019
@bedevere-bot bedevere-bot removed the awaiting core review label Jun 24, 2019
@methane
methane deleted the ascii-fromstring branch June 24, 2019 03:30
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
@methane @lisroach
bpo-37348: optimize decoding ASCII string (pythonGH-14283)
6634958
`_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
@methane @DinoV
bpo-37348: optimize decoding ASCII string (pythonGH-14283)
04efd0d
`_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

Reviewers

@vstinner vstinner vstinner left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

performance Performance or resource usage

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@methane @vstinner @brettcannon @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.