web-miner
web-miner copied to clipboard
Make the serializer JSON independent to further comply with "clean architecture"
See the discussion on this issue on Slack
Right now the Response is JSON dependent (end of the file):
return Response(
json.dumps(response.value, cls=ser.ArxivDocEncoder),
mimetype="application/json",
status=STATUS_CODES[response.type],
)
One way to let objects interact is to use composition. This can be a good way to decouple functions. See this article to fresh up the ideas of delegation in OOP in Python
I would also add this source for how to refactor python properly
And regarding the serialization method itself, json is quite slow. ujson is already faster, and there are also other alternatives in the benchmark competition