CERT-Polska / karton

Distributed malware processing framework based on Python, Redis and S3.
https://karton-core.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
381 stars 45 forks source link

Feature: Task.to_dict #216

Closed psrok1 closed 1 year ago

psrok1 commented 1 year ago

Serialization is splitted to Task.to_dict that is then used by Task.serialize

It should be a bit more efficient than json.dumps(cls=...) and enables us to use orjson for serialization as well:

In [10]: timeit.timeit(lambda: karton.core.task.Task({}).serialize(), number=100000)
Out[10]: 1.5992015590891242

vs

In [6]: timeit.timeit(lambda: karton.core.task.Task({}).serialize(), number=100000)
Out[6]: 1.1377838689368218

closes #209