chore: use orjson in streaming event JSON serialisation for performance improvement (#24763)

This commit is contained in:
Bowen Liang
2025-08-29 14:06:07 +08:00
committed by GitHub
parent e47bfd2ca3
commit 3d5a4df9d0
3 changed files with 45 additions and 34 deletions

11
api/libs/orjson.py Normal file
View 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)