-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Small speed up to cookiejar filter_cookies #8535
Conversation
Using str.format is ~16% faster than the lambda
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8535 +/- ##
=======================================
Coverage 97.67% 97.67%
=======================================
Files 107 107
Lines 33286 33288 +2
Branches 3918 3916 -2
=======================================
+ Hits 32513 32515 +2
Misses 559 559
Partials 214 214
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: Sam Bull <[email protected]>
thanks |
Backport to 3.10: 💚 backport PR created✅ Backport PR branch: Backported as #8537 🤖 @patchback |
Co-authored-by: Sam Bull <[email protected]> (cherry picked from commit 7108d64)
…_cookies (#8537) **This is a backport of PR #8535 as merged into master (7108d64).** <!-- Thank you for your contribution! --> ## 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 ```python 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: J. Nick Koston <[email protected]>
What do these changes do?
Small speed up to cookiejar
Using
str.format
is ~16% faster than the lambdafollowup to #7944 (comment). I was hoping to use
join
there but later realizedstr.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