Closed davidbrochart closed 1 year ago
Thanks David! Well, actually I followed what Tom Christie recommended in this thread: https://github.com/encode/httpx/issues/304#issuecomment-1320023905
Since I trust him to know way better than me what is better, I didn't question the choice 😬
Thanks for the answer, that makes sense.
I'll probably use httpx-ws
very soon :smiley:
@aaugustin Do you have a list of pros and cons about wsproto
and websockets
regarding the sans-io implementation?
Asking here because it may give some insights... :man_shrugging:
In terms of API, websockets does more for you:
In terms of performance, you should see a big difference in favor of websockets when dealing with large frames (like, 1MB) because this code in wsproto, even though it's reasonably optimized Python, is nowhere near as fast as that code in websockets. This is actually a big performance bottleneck of all pure Python implementations.
I believe that websockets a bit more battle-tested as it predates wsproto by a few years — some super-edge-case bugs were ironed out over the years.
You're welcome to have Opinions about websockets' regex-based HTTP implementation. Well, it's fast, I cannot remember having to fix embarrassing bugs, and OSS-Fuzz didn't find anything after running billions of test cases. So I guess it's a viable way implement the required subset of HTTP for a WebSocket handshake? Anyway, it doesn't matter here, as you're planning to use httpx for parsing HTTP messages.
The documentation of websockets' Sans-I/O layer tells you the basics but isn't at the same level as the documentation of the rest of the library — because so few people will integrate the Sans-I/O layer that I can support them individually. It's probably more useful to check this PR: https://github.com/aaugustin/websockets/pull/1245/files (or the actual code in the library once I merge it).
There may be other aspects in which wsproto is superior to websockets. I know where I put my efforts in websockets; I don't know where the wsproto crew invested!
Beyond that, WebSocket is a relatively small protocol so you will likely find pretty much the same code. At some point, websockets had higher performance; then everyone adopted the same ideas and I'm not sure there's a
Thanks @aaugustin :pray:
Hi @frankie567, interesting project! Out of curiosity, why did you choose
wsproto
over websockets?