chore: use orjson in streaming event JSON serialisation for performance improvement (#24763)
This commit is contained in:
parent
e47bfd2ca3
commit
3d5a4df9d0
3 changed files with 45 additions and 34 deletions
11
api/libs/orjson.py
Normal file
11
api/libs/orjson.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from typing import Any, Optional
|
||||
|
||||
import orjson
|
||||
|
||||
|
||||
def orjson_dumps(
|
||||
obj: Any,
|
||||
encoding: str = "utf-8",
|
||||
option: Optional[int] = None,
|
||||
) -> str:
|
||||
return orjson.dumps(obj, option=option).decode(encoding)
|
||||
Loading…
Add table
Add a link
Reference in a new issue