Open kevinlul opened 1 year ago
Hello there,
Sorry to barge in, There's an alternative you may be interested in. https://github.com/jawah/niquests
This is a drop-in-worthy replacement for Requests that ships with modern capabilities and allows you a painless transition. I can answer any concerns you may have.
Describe the solution you'd like
prawcore is currently tied to
requests
and asyncprawcore toaiohttp
. I like howhttpx
has both async and sync capabilities and would like to use one HTTP library in my project as I will be calling other APIs as well. I would also like to see if httpx's HTTP/2 implementation provides any latency improvement over HTTP/1.1 implementations.httpx
is broadly compatible withrequests
but httpx.Client does not implement the exact API as requests.Session: https://www.python-httpx.org/compatibility/Naively constructing praw.Reddit with
requestor_kwargs={"session": client}
whereclient = Client(http2=True)
, I was able to run praw's quickstart example listing 10 hot submissions with the below two patches:https://github.com/praw-dev/prawcore/blob/16fe48c3b4ea82c18dca0985e79828676c988321/prawcore/auth.py#L51
replace with
data=data
,httpx
only supports dict syntax and not a list of tupleshttps://github.com/praw-dev/prawcore/blob/16fe48c3b4ea82c18dca0985e79828676c988321/prawcore/sessions.py#L210
remove entirely, as httpx names the parameter differently and defaults to no redirects anyway
Describe alternatives you've considered
No response
Additional context
https://praw.slack.com/archives/CRZ00QLC9/p1681666057106319