oxan / djangorestframework-dataclasses

Dataclasses serializer for Django REST framework
BSD 3-Clause "New" or "Revised" License
431 stars 28 forks source link

How about performance ? #37

Closed Kub-AT closed 3 years ago

Kub-AT commented 3 years ago

Hi,

How about performance ? Did you test large objects serialization performance ?

djangorestframework-dataclasses vs build-in drf serializer ?

oxan commented 3 years ago

I haven't done any benchmarks, but I'd expect it to be slower. The main reason is that the serializer has to rediscover and recreate the fields every time it is created. We could cache some information to improve this a bit, but it is mainly a limitation in the design of DRF's serializers. DRF's ModelSerializer also suffers from this problem (see encode/django-rest-framework#7093).

intgr commented 3 years ago

If you're looking for high-performance (de)serialization, you might try Pydantic instead: https://pydantic-docs.helpmanual.io/benchmarks/