Skip to content
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-44002: Switch to lru_cache in urllib.parse. #25798

Merged
merged 7 commits into from
May 12, 2021

Conversation

gpshead
Copy link
Member

@gpshead gpshead commented May 1, 2021

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
Copy link
Member Author

gpshead commented May 1, 2021

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 gpshead requested a review from orsenthil May 1, 2021 22:55
Lib/urllib/parse.py Outdated Show resolved Hide resolved
Copy link
Member Author

@gpshead gpshead left a comment

Choose a reason for hiding this comment

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

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.

@rhettinger
Copy link
Contributor

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

@orsenthil
Copy link
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 gpshead self-assigned this May 3, 2021
@gpshead
Copy link
Member Author

gpshead commented May 3, 2021

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

@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

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

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

Excellent change. @gpshead :)

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