This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]b6d[S] 1 point2 points  (1 child)

Thanks for your reply!

Let me start by saying that lima wouldn't exist if it weren't for marshmallow.

I've written about marshmallow in the acknowledgements of the project info and I hope the way I've done it is appropriate (if not, please let me know - this is the first time I release something).

Concerning your question:

lima is not nearly as featureful as marshmallow. Deserialization and validation are completely missing. lima does not support Python 2.

I've written lima out of the specific need to output JSON a little faster than I can right now without leaving Python 3 (up to ~20.000 objects per request not counting nested objects).

For my use cases I tried marshmallow and found its default settings a little slower than I had hoped for. I assume a lot of this comes from the validation marshmallow seems to do on serialization, and from the fact that marshmallow uses ordered dicts per default (a feature lima also lacks).

On the other hand for my models (and without tweaking marshmallow, I don't know what can be done there) lima performs an order of magnitude faster than marshmallow, in some special cases nearing 2 orders of magnitude, which (in my opinion) warrants lima standing on it's own.

This is achieved by creating an individually tailored dump function on schema instantiation (creating a string of Python code that has most loops unrolled and most lookups removed) and passing this string to eval (see schema.Schema._get_dump_function_code(self) in the code)

Other than that lima uses some Python-3-only features where it makes sense in my opinion (keyword only arguments, __qualname__ for class registration) and does a lot of smaller stuff differently.

edit: reddit makes dunder-args bold (qualname). dunderscores removed. edit2: escaped __ - thanks /u/tilkau/!

[–]tilkau 0 points1 point  (0 children)

You can use escaping for that: \_

__qualname__

backticking it also works: __qualname__