All projects
Project notes

django-rapid: msgspec Serialization and Validation for Django

Fast JSON serialization and request validation for Django views using msgspec. A FastAPI-style decorator and Schema class that replace DRF serializers on hot endpoints and cut serialization overhead.

PythonDjangomsgspecJSONAPIPerformanceOpen Source

django-rapid grew out of production work where DRF serializers were the dominant cost on busy endpoints. It swaps them for msgspec, with a decorator that validates the request body against a schema and serializes the return value.

@validate(UserIn, response_schema=UserOut)
def create_user(request):
    data = request.validated_data
    return User.objects.create_user(data.username, data.email, data.password)

It works with function views and class-based APIViews, and you can adopt it one endpoint at a time. The ideas here later fed directly into django-bolt.