[ perf ] Replace json-> orjson in hot path (#11221)
Signed-off-by: vincentzed <207368749+vincentzed@users.noreply.github.com>
This commit is contained in:
@@ -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"]))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user