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 — Improve performance of `http.cookiejar.join_header_words` · Issue #128982 · python/cpython

Improve performance of http.cookiejar.join_header_words #128982

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Improve performance of http.cookiejar.join_header_words#128982
Copy link
Assignees
picnixz
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@picnixz
picnixz
opened on Jan 18, 2025
Issue body actions

Feature or enhancement

Proposal:

Currently, we use if not re.search(r"^\w+$", v):. This can be replaced by if not v.isalnum() and '_' not in v. Benchmarks are as follows:

$ ./python -m pyperf timeit -s 'x = [[("text/plain", None), ("charset", "iso-8859-1\"")]]; from http.cookiejar import join_header_words as f' 'f(x)'
Mean +- std dev: [ref] 795 ns +- 8 ns -> [new] 604 ns +- 20 ns: 1.32x faster

It doesn't help having a compiled regex by the way.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative #128983
  • gh-128982: Revert "#128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative (GH-128983)" and add tests #130584

Activity

  1. picnixz
    added
    performancePerformance or resource usagePerformance or resource usage
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 18, 2025
  2. picnixz
    self-assigned this
    on Jan 18, 2025
  3. encukou
    added a commit that references this issue on Feb 26, 2025

    gh-128982: Substitute regular expression in `http.cookiejar.join_head…

    56e1900
  4. encukou commented on Feb 26, 2025

    @encukou
    encukou
    on Feb 26, 2025
    Member
    More actions

    Thank you!

  5. encukou
    closed this as completedon Feb 26, 2025
  6. serhiy-storchaka commented on Feb 26, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on Feb 26, 2025
    Member
    More actions

    This is incorrect change. For example, it produces incorrect results for "foo;_" and "foo_bar".

  7. serhiy-storchaka
    reopened this on Feb 26, 2025
  8. encukou commented on Feb 26, 2025

    @encukou
    encukou
    on Feb 26, 2025
    Member
    More actions

    Oof, thanks for noticing.
    I'll revert and add a test.

  9. encukou
    added 2 commits that reference this issue on Feb 26, 2025

    Revert "pythongh-128982: Substitute regular expression in `http.cooki…

    9d37429

    gh-128982: Revert "#128982: Substitute regular expression in http.coo…

    9e474a9
  10. serhiy-storchaka commented on Feb 27, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on Feb 27, 2025
    Member
    More actions

    \w here looks arbitrary. And it is. There are other red flags. See #130631.

  11. picnixz commented on Mar 1, 2025

    @picnixz
    picnixz
    on Mar 1, 2025
    MemberAuthor
    More actions

    I'll close this one and we'll move to 130631

  12. picnixz
    closed this as not plannedon Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — 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.