Allow use of orjson instead of json

The difference in speed seems negligible at start up, which is when
most time is taken for actually parsing JSON. I could potentially be
missing something but profiling didn't point to any discernable
difference.
This commit is contained in:
Rapptz
2021-07-05 04:01:19 -04:00
parent e0a9365d61
commit 88d825a803
4 changed files with 27 additions and 6 deletions

View File

@@ -99,7 +99,7 @@ async def json_or_text(response: aiohttp.ClientResponse) -> Union[Dict[str, Any]
text = await response.text(encoding='utf-8')
try:
if response.headers['content-type'] == 'application/json':
return json.loads(text)
return utils.from_json(text)
except KeyError:
# Thanks Cloudflare
pass