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

[PR #8535/7108d646 backport][3.10] Small speed up to cookiejar filter_cookies #8537

Conversation

patchback[bot]
Copy link
Contributor

@patchback patchback bot commented Jul 25, 2024

This is a backport of PR #8535 as merged into master (7108d64).

What do these changes do?

Small speed up to cookiejar

Using str.format is ~16% faster than the lambda

followup to #7944 (comment). I was hoping to use join there but later realized str.format will take *args

Are there changes in behavior for the user?

no

Is it a substantial burden for the maintainers to support this?

no

benchmark

import timeit
import itertools

_FORMAT_PATH = "{0}/{1}".format

path = "lolonglonglonglonglonglongng/path/to/a/file"

print(
    timeit.timeit(
        'itertools.accumulate(path.split("/"), _FORMAT_PATH)', globals=globals()
    )
)


print(
    timeit.timeit(
        'itertools.accumulate(path.split("/"), lambda x, y: f"{x}/{y}")',
        globals=globals(),
    )
)

Co-authored-by: Sam Bull <git@sambull.org>
(cherry picked from commit 7108d64)
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.50%. Comparing base (95897b1) to head (b94762b).
Report is 7 commits behind head on 3.10.

Additional details and impacted files
@@            Coverage Diff             @@
##             3.10    #8537      +/-   ##
==========================================
- Coverage   97.54%   97.50%   -0.05%     
==========================================
  Files         108      108              
  Lines       33549    33520      -29     
  Branches     4027     4027              
==========================================
- Hits        32724    32682      -42     
- Misses        601      612      +11     
- Partials      224      226       +2     
Flag Coverage Δ
CI-GHA 97.41% <100.00%> (-0.04%) ⬇️
OS-Linux 97.08% <100.00%> (-0.03%) ⬇️
OS-Windows 94.66% <100.00%> (-0.06%) ⬇️
OS-macOS 96.81% <100.00%> (+0.03%) ⬆️
Py-3.10.11 96.91% <100.00%> (+0.02%) ⬆️
Py-3.10.14 96.87% <100.00%> (+0.03%) ⬆️
Py-3.11.9 97.10% <100.00%> (+0.03%) ⬆️
Py-3.12.4 97.22% <100.00%> (+0.02%) ⬆️
Py-3.8.10 94.47% <100.00%> (+0.02%) ⬆️
Py-3.8.18 96.76% <100.00%> (+0.03%) ⬆️
Py-3.9.13 96.60% <100.00%> (-0.29%) ⬇️
Py-3.9.19 96.88% <100.00%> (+0.03%) ⬆️
Py-pypy7.3.16 ?
VM-macos 96.81% <100.00%> (+0.03%) ⬆️
VM-ubuntu 97.08% <100.00%> (-0.03%) ⬇️
VM-windows 94.66% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco bdraco enabled auto-merge (squash) July 25, 2024 18:36
@bdraco bdraco merged commit 3baa6de into 3.10 Jul 25, 2024
31 of 32 checks passed
@bdraco bdraco deleted the patchback/backports/3.10/7108d6469d20dd48919d312b2c654aef867ebe51/pr-8535 branch July 25, 2024 18:43
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.

1 participant