Skip to content

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

Merged
bdraco merged 1 commit into3.10from
patchback/backports/3.10/7108d6469d20dd48919d312b2c654aef867ebe51/pr-8535
Jul 25, 2024
Merged

[PR #8535/7108d646 backport][3.10] Small speed up to cookiejar filter_cookies#8537
bdraco merged 1 commit into3.10from
patchback/backports/3.10/7108d6469d20dd48919d312b2c654aef867ebe51/pr-8535

Conversation

@patchback
Copy link
Copy Markdown
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 <[email protected]>
(cherry picked from commit 7108d64)
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (3.10@5621ecf). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.10    #8537   +/-   ##
=======================================
  Coverage        ?   97.56%           
=======================================
  Files           ?      108           
  Lines           ?    33520           
  Branches        ?     4027           
=======================================
  Hits            ?    32704           
  Misses          ?      594           
  Partials        ?      222           
Flag Coverage Δ
CI-GHA 97.47% <100.00%> (?)
OS-Linux 97.14% <100.00%> (?)
OS-Windows 94.73% <100.00%> (?)
OS-macOS 96.81% <100.00%> (?)
Py-3.10.11 96.91% <100.00%> (?)
Py-3.10.14 96.87% <100.00%> (?)
Py-3.11.9 97.10% <100.00%> (?)
Py-3.12.4 97.22% <100.00%> (?)
Py-3.8.10 94.47% <100.00%> (?)
Py-3.8.18 96.76% <100.00%> (?)
Py-3.9.13 96.91% <100.00%> (?)
Py-3.9.19 96.88% <100.00%> (?)
Py-pypy7.3.16 96.44% <100.00%> (?)
VM-macos 96.81% <100.00%> (?)
VM-ubuntu 97.14% <100.00%> (?)
VM-windows 94.73% <100.00%> (?)

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
@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