[ perf ] Replace json-> orjson in hot path (#11221)

Signed-off-by: vincentzed <207368749+vincentzed@users.noreply.github.com>
This commit is contained in:
Vincent Zhong
2025-10-12 08:30:58 -04:00
committed by GitHub
parent 7b064f04f8
commit a220536f40
13 changed files with 32 additions and 20 deletions

View File

@@ -4,6 +4,7 @@ from functools import lru_cache
from typing import Any, Dict, List, Optional
import dill
import orjson
import torch
@@ -12,7 +13,7 @@ def _cache_from_str(json_str: str):
"""Deserialize a json string to a Callable object.
This function is cached to avoid redundant deserialization.
"""
data = json.loads(json_str)
data = orjson.loads(json_str)
return dill.loads(bytes.fromhex(data["callable"]))