ethanhs / abserde

Generate fast JSON parsers based on type stubs
Apache License 2.0
13 stars 0 forks source link

Optimize deserialize #6

Closed ethanhs closed 4 years ago

ethanhs commented 5 years ago

Right now we classes in an enum to make things simple. This is actually rather slow, especially for single class stubs. We should remove this.

(testing shows this can be a 2x+ slow down!)

ethanhs commented 4 years ago

It seems this will be harder to do away with than I initially thought.

For now, it seems acceptable to be slower if you don't specify what type you want to deserialize to, and we can document dumps as having a signature Callable[[Union[str, bytes, bytearray], Type[T]], T].

To make deserialization faster in the enum case, we can implement deserialize for a struct with all attributes of all the structs we have. NB: use default attributes to allow for missing fields.

ethanhs commented 4 years ago

This was not as bad as I thought it would be! I still need to add support for the above signature, but that will be a new issue.