3 ms·
I do wish Django REST Framework shipped with faster serializer code.
by systemspeed 8y ago
I do wish Django REST Framework shipped with faster serializer code.
- Nextgrid 8y agoYou can use Serpy for that, although it will require some hacking for deserialization (a previous client of mine had a custom-built solution that used Serpy for responses but plain Form classes for parsing requests, but that seemed fine and they were handling 3k/requests per second at peak time).
- tclancy 8y agoI never quite got Serpy working, but swapping to uJSON and the DRF renderer[0] helped quite a bit in some cases. [0] https://github.com/gizmag/drf-ujson-renderer https://github.com/gizmag/drf-ujson-renderer
- systemspeed 8y agoThat's essentially what we ended up doing, selectively using Serpy for certain slow responses. It still felt hackish though, as though we were taking the brakes off certain responses because we knew they needed little validation (IIRC). DRF serializers still need work; marshmallow provides a similar feature set to DRF but serializes almost twice as fast: https://voidfiles.github.io/python-serialization-benchmark/ https://voidfiles.github.io/python-serialization-benchmark/ Disclaimer: The above is not my project