miLibris / flask-rest-jsonapi

Flask extension to build REST APIs around JSONAPI 1.0 specification.
http://flask-rest-jsonapi.readthedocs.io
MIT License
597 stars 153 forks source link

Using toastedmarshmallow for JIT #192

Open Rishi321 opened 4 years ago

Rishi321 commented 4 years ago

Has this library been tested with ToastedMarshmallow? We have been using this library to great effect recently in a project (for about 8 months), but we're now seeing some performance hits during the Marshmallow serialization (sometimes 100's of ms) when dealing with many objects (100's)

I've seen people talk about ToastedMarshmallow and notice that the compute_schema recreates schema instances everytime, according to the ToastedMarshmallow documentation this will reduce the gain heavily.

Is there a reason we recreate schema objects every time? If not, what would be the best way to change the code to allow one schema object per resource?

Rishi321 commented 4 years ago

Ok, I see that every request may end up with a new schema based on the includes and other attributes, but when calling these from an API client there will be only a subset in use.

Caching the compute schema output would work, however the arguments will cause problems since qs and include are objects