-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Avoid an unnecessary computation of the length of data for non-stream requests (which determine content-length based upon body content). #5496
Conversation
… requests (which determines content-length based upon body content).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @dbaxa, this seems reasonable. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to use a set here, was there a reason beyond avoiding a second iteration?
@nateprewitt when profiling requests, it resulted in a reduction in execution time & it makes more sense to me. |
@dbaxa the net gain of the change is pretty minor and we're just swapping memory usage for speed. Since it's not really part of what the PR was raised for let's consolidate this to just the super_len encapsulation and I think we'll be set. |
@dbaxa so performance isn't the top concern for Requests. Further, evidence of improvements goes a long way towards convincing others |
2084872
to
71a05cf
Compare
@sigmavirus24 I can provide some evidence / data if desired. To be honest some of the minor optimisations that can be made might not be suitable for requests to take. However, there are certainly some areas that requests could do with improvements with/to (e.g. the slowness of the code executed as part of obtaining proxy information inside of an already created session object for each/every generated request. I have a benchmark that shows that for one non-cached request & 9999 cached requests, using cachecontrol, ~10 seconds can be saved by setting As an aside, is there a reason to prefer using a tuple instead of a set for the method check (other than the memory usage trade off) ? |
Agreed.
I'm not a maintainer, but in the past PRs with no description of the changes without previously discussing them with the maintainers often feel like "drive-by" contributions with no context and no clear value. That makes them easy to dismiss, forget about, or just close outright. I'd find these to be a higher quality if you explained (in a couple sentences or less) how you found the problem, and the rough measured performance improvements (including OS, python versions tested, etc.).
Yes well
I'm fairly certain cachecontrol is no longer maintained unfortunately
🤷 |
Sure, I'll try to provide some more context in future pull requests.
That's fine as users who want not to hit the relative slowness encountered by
I am not sure. I have also yet to look into raising an improvement/suggestion for @ionrock 's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @dbaxa!
No description provided.