Pregunta

Currently we are using json to code\decode data in our data processing software. But we found any JSON implementation slow - we tried simplejson, ujson etc. - so we're looking for an alternative.

We use some other programs to work with data, and newline symbol is a terminator for each piece of data. In other words, we'd like to avoid serializators that might put newline symbol into dumped objects.

I tried msgpack on a small piece of data, and it seems it does not put newline symbol (pickle does). And it's quite fast.

Could anybody tell me if newlines will not be used in any dumped object, if I use msgpack packb() method? Thanks

¿Fue útil?

Solución

Yes, msgpack does add newlines (unfortunately):

>>> import msgpack
>>> s = msgpack.packb({"a":10,"b":13})
>>> s
'\x82\xa1a\n\xa1b\r'
>>> '\r' in s
True
>>> '\n' in s
True
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top