2 hours ago · 7 min read1377 words · Tech · hide · 0 comments

It’s another day, another new package day here. Say hello to django-msgspec, a package of drop-in replacements for Django and Django REST Framework (DRF) components backed by msgspec. msgspec is a C-based serialization library covering JSON, MessagePack, YAML, and TOML, with optional schema validation through typed Struct classes. Its JSON encoder and decoder are several times faster than the standard library’s, which makes django-msgspec a cheap performance win in the parts of Django that handle JSON. Features There’s a version of JsonResponse: from django_msgspec.http import JsonResponse def index(request): return JsonResponse({"title": "Hello, world!"}) …a test client with matching test case classes: from django_msgspec.test import SimpleTestCase class IndexTests(SimpleTestCase): def test_index(self): response = self.client.get("/", headers={"accept": "application/json"}) assert response.status_code == 200 # response.json() uses msgspec to parse the response body assert…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.