adewes / blitzdb

Blitz is a document-oriented database for Python that is backend-agnostic. It comes with a flat-file database for JSON documents and provides MongoDB-like querying capabilities.
http://blitzdb.readthedocs.org
MIT License
331 stars 37 forks source link

Support for ujson #72

Open celestianx opened 7 years ago

celestianx commented 7 years ago

Hi, ujson is recognized as a really fast json encoder/decoder, would it be possible to choose the json encoder/decoder library as part of arguments

adewes commented 7 years ago

Hey @celestian02 , that should be easy to do! Do you want to make the change and open a PR?

You'd need to modify two files: https://github.com/adewes/blitzdb/blob/master/blitzdb/backends/file/serializers.py

Here you'd need to add a new serializer class that imports "ujson" instead of "json" (you can have a look at the CJsonSerializer class for an example)

https://github.com/adewes/blitzdb/blob/master/blitzdb/backends/file/backend.py

Here you'd just need to add 'ujson' to the list of serializers (again, you can have a look at the 'cjson' example).

Let me know if I can help you with anything!