python-hyper / h11

A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
https://h11.readthedocs.io/
MIT License
490 stars 62 forks source link

Inline the validate() function #119

Open bluetech opened 3 years ago

bluetech commented 3 years ago

This is based on #118, please look at the last commit only. (Sorry for the jungle of PRs, I can rebase them whichever way).


It somewhat obscures the control flow and adds some non-trivial overhead.

Inline it in favor of the direct match/if combination.

On the bench/ microbenchmark:

Before: 10700.2 requests/sec
After : 11334.0 requests/sec
pgjones commented 3 years ago

I also prefer this approach, however as it more of a preference question I'll wait for more views.

tomchristie commented 3 years ago

I also prefer this approach, however as it more of a preference question I'll wait for more views.

From the last commit, that seems okay as a trade-off, yup. Tho I'd probably also want to review again once there's an up to date PR for it, and have the micorbenchmark re-run against the latest PR-against-master.