3 ms·
What did you use in place of the DRF serialization to get from DB -> json response?
by buttersbrian 6y ago
What did you use in place of the DRF serialization to get from DB -> json response?
- Bedon292 6y agoFastAPI uses Pydantic under it for python objects. And we have been tinkering with orjson for the actual json serialization, since it appears to be the winner in json serialization at the moment.
- dec0dedab0de 6y agoWas there still a significant speedup using the standard library json module? For the DB requests Are you writing sql directly, using a different ORM, or something like sqlalchemy core that makes sql pythonic without being an ORM?
- Bedon292 6y agoYeah, the main improvement was seen even before playing with orjson. It did help too I think, but only started it yesterday so haven't actually profiled the two side by side. To have real numbers. And it uses SQLAlchemy under the hood. Can use all of it. But if you want full async all the way down, can just use core and something like encode/databases for the DB access.
- MapleWalnut 6y agoWhy didn't you use Pydantic with Django if the DRF serializers were too slow? You can also skip the object serialization from the ORM and work with python dicts directly to significantly improve serialization performance from the database.