Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm struggling with this one. It looks to me like all we've saved is one attribute access...
With the dict, I was expecting a reversal of logic or something here, like
for enc in accept_encoding: CONTENT_CODINGS.get(enc)
.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.
Iterating enums in python is surprisingly expensive and good chunk of its the
__get__
._start_compression
was the most expensive call in_prepare_headers
before:We save:
.items()
, but thats all going to be in native code for sure)... maybe we can save more here but I was thinking the
in
3x was cheaper than adict
lookupZoomed in on
_prepare_headers
before the change:Zoomed in on
_start_compression
before the change: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.
a dict get might make sense if we parsed the string but parsing is probably more expensive
Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5