Skip to content

gh-160690: Speed up urllib.parse.unquote() for ASCII input - #160691

Open
f4hy wants to merge 6 commits into
python:mainfrom
f4hy:unquote-ascii
Open

f4hy wants to merge 6 commits into
python:mainfrom
f4hy:unquote-ascii

Conversation

@f4hy

@f4hy f4hy commented Oct 26, 2026 •

Copy link
Copy Markdown

For pure ASCII input, we can skip the regex/generator path in unquote() and decode the result of _unquote_impl() directly. The regex would match the whole string as a single chunk anyway, so the result is identical.

Benchmarks are in the issue but up to 2x faster in the micro-benchmark for the common short ascii input.

Added a test checking that the fast path and the general path decode escapes the same way.

Resolves #160690

@python-cla-bot

python-cla-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Oct 26, 2026
Comment thread Lib/urllib/parse.py
@eendebakpt

Copy link
Copy Markdown
Contributor

@serhiy-storchaka @gpshead Could you have look at the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Speed up urllib.parse.unquote() for ASCII input

2 participants