Open bdraco opened 1 month ago
Its the 350000 calls to .items()
Not a regression but noticed it while investigating another issue
Is this because they use a predicate? It's not clear how much we could improve it if they want to use predicate..
Yes they use a predicate. I usually stew on these type of issues for a bit until I come up with a better algorithm to reduce the overhead. Sometimes they never get solved but often it just takes me a long time to reach a solution.
heapq is probably the solution... but those type of constructs are always a bit painful to get right
The predicate would still need to run against every morsel, right?
The only way I see of reducing that is to completely change the predicate API, so it can do something like skipping the entire cookie for a (domain. path)
key without checking the individual morsels. It'd probably also need to have a good idea of whether the majority of cookies will be kept or deleted, if the latter then it can just store the ones to keep, then clear the cookiejar and readd them, instead of deleting all the other cookies one-by-one.
Describe the bug
To Reproduce
I think the trace source if python-kasa since it clear the cookie jar on every connection
Expected behavior
clear should be fast
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
Linux
Related component
Client
Additional context
No response
Code of Conduct