FastAPI使用ORJSONResponse作为默认的响应类型

FastAPI默认使用Python的标准库来做json解析,如果换成rust编写的orjson,速度上会快一些

1. 安装依赖

pip install orjson

2. 设置为默认响应类型

from fastapi.responses import ORJSONResponse

app = FastAPI(title='xxx', default_response_class=ORJSONResponse)

你可能感兴趣的:(fastapi)