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

Use functools.lru_cache in urllib.parse instead of 1996 custom caching #88168

Closed
gpshead opened this issue May 1, 2021 · 3 comments
Closed
Assignees
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@gpshead
Copy link
Member

gpshead commented May 1, 2021

BPO 44002
Nosy @gpshead
PRs
  • bpo-44002: Switch to lru_cache in urllib.parse. #25798
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gpshead'
    closed_at = <Date 2021-05-12.00:02:19.781>
    created_at = <Date 2021-05-01.18:17:15.725>
    labels = ['type-feature', 'library', '3.11']
    title = 'Use functools.lru_cache in urllib.parse instead of 1996 custom caching'
    updated_at = <Date 2021-05-12.00:02:19.781>
    user = 'https://github.com/gpshead'

    bugs.python.org fields:

    activity = <Date 2021-05-12.00:02:19.781>
    actor = 'gregory.p.smith'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2021-05-12.00:02:19.781>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)']
    creation = <Date 2021-05-01.18:17:15.725>
    creator = 'gregory.p.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44002
    keywords = ['patch']
    message_count = 3.0
    messages = ['392614', '392619', '392620']
    nosy_count = 1.0
    nosy_names = ['gregory.p.smith']
    pr_nums = ['25798']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44002'
    versions = ['Python 3.11']

    @gpshead
    Copy link
    Member Author

    gpshead commented May 1, 2021

    urllib.parse has custom caching code for both urlsplit() and quote(). From 1996.

    3fd32ec
    7449540

    with a truthful comment added by Nick in 2010 that we should just use functools.lru_cache.

    9fc443c#diff-b3712475a413ec972134c0260c8f1eb1deefb66184f740ef00c37b4487ef873e

    time to clean up this cruft and do that.

    I'm waiting for after the 3.10 cut and a still in progress urllib.parse security fix to land before rebasing my soon to be attached PR to avoid code conflicts.

    @gpshead gpshead added the 3.11 only security fixes label May 1, 2021
    @gpshead gpshead self-assigned this May 1, 2021
    @gpshead gpshead added stdlib Python modules in the Lib dir type-feature A feature request or enhancement 3.11 only security fixes labels May 1, 2021
    @gpshead gpshead self-assigned this May 1, 2021
    @gpshead gpshead added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 1, 2021
    @rhettinger
    Copy link
    Contributor

    While you're cleaning up the module, take a look at the Quoter class. It overrides __init__ and __missing__, so Quoter is not using any of the defaultdict features at all. I'm thinking it could just inherit from dict.

    @gpshead
    Copy link
    Member Author

    gpshead commented May 1, 2021

    Yeah, the Quoter class seems a little odd...

    Past notes of some the caching performance around the character quoting for quote() can be found in https://bugs.python.org/issue1285086 circa 2005-2010.

    @gpshead gpshead closed this as completed May 12, 2021
    @gpshead gpshead closed this as completed May 12, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants