← 返回首页
bpo-44002: Switch to lru_cache in urllib.parse. by gpshead · Pull Request #25798 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-44002: Switch to lru_cache in urllib.parse.#25798

Merged
gpshead merged 7 commits into
python:mainfrom
gpshead:non-90s-urlparse-cache
May 12, 2021
Merged

bpo-44002: Switch to lru_cache in urllib.parse.#25798
gpshead merged 7 commits into
python:mainfrom
gpshead:non-90s-urlparse-cache

Conversation

gpshead commented May 1, 2021
edited by miss-islington
Loading

Copy link
Copy Markdown
Member

urllib.parse now uses functool.lru_cache for its internal URL splitting and
quoting caches instead of rolling its own like its the 90s.

The undocumented internal Quoted class is now deprecated, for removal in 3.14.
No existing users were found.

clear_cache() is kept as twisted, gevent, and our own regression test runner were
found to be using it in their test suites.

https://bugs.python.org/issue44002

Automerge-Triggered-By: GH:gpshead

urllib.parse now uses functool.lru_cache for its internal URL splitting and quoting caches instead of rolling its own like its the 90s. The undocumented internal Quoted class and clear_cache() APIs are now deprecated, for removal in 3.14.

gpshead commented May 1, 2021

Copy link
Copy Markdown
Member Author

I won't merge this until after the 3.10 branch is cut and all of the https://bugs.python.org/issue43882 fixes are in.

gpshead requested a review from orsenthil May 1, 2021 22:55
Comment thread Lib/urllib/parse.py Outdated Show resolved Hide resolved
Comment thread Lib/urllib/parse.py Show resolved Hide resolved
Comment thread Lib/test/test_urlparse.py Outdated Show resolved Hide resolved

gpshead left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

The test that's failing due to an unexpected BytesWarning in CI is annoying... that means we need to use lru_cache(typed=True) on the urlsplit decorator for safety to avoid other people who enable BytesWarning from seeing that warning.

Comment thread Lib/urllib/parse.py Show resolved Hide resolved

Copy link
Copy Markdown
Contributor

It looks like the Travis CI failed only because of excess whitespace. Running 'make patchcheck' would likely clear it.

Copy link
Copy Markdown
Member

This final change, which addressed the review comments from the reviewers looks good to me.

twisted, gevent, and our own libregrtest use it in test suites. We'll keep it for them. ... and skip Pending on Quoter's DeprecationWarning. No uses of that have been found externally. Also reoragnizes the unittest a bit to be cleaner and fixes a whitespace problem.
gpshead self-assigned this May 3, 2021

gpshead commented May 3, 2021

Copy link
Copy Markdown
Member Author

Status: awaiting a copy of #25853 to be merged into main before merging this one.

Comment thread Lib/urllib/parse.py Show resolved Hide resolved

Copy link
Copy Markdown
Contributor

@gpshead: Status check is done, and it's a failure ❌ .

Copy link
Copy Markdown
Contributor

@gpshead: Status check is done, and it's a success ❌ .

gpshead merged commit d597fdc into python:main May 12, 2021
gpshead deleted the non-90s-urlparse-cache branch May 12, 2021 00:01

Copy link
Copy Markdown
Member

Excellent change. @gpshead :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

Footer

© 2026 GitHub, Inc.