擅长:python、mysql、java
<p>如果你想快点,<a href="https://github.com/lz4/lz4" rel="nofollow noreferrer">try lz4</a>。
如果你想压缩得更好,<a href="https://docs.python.org/3/library/lzma.html" rel="nofollow noreferrer">go for lzma</a>。</p>
<blockquote>
<p>Are there any other better ways to compress json to save memory in
redis(also ensuring light weight decoding afterwards)?</p>
<p>How good a candidate would be msgpack [<a href="http://msgpack.org/]" rel="nofollow noreferrer">http://msgpack.org/]</a>?</p>
</blockquote>
<p>Msgpack速度相对较快,内存占用较小。但是<a href="https://pypi.python.org/pypi/ujson" rel="nofollow noreferrer">ujson</a>对我来说通常更快。
您应该在数据上比较它们,测量压缩和解压缩速率以及压缩比。</p>
<blockquote>
<p>Shall I consider options like pickle as well?</p>
</blockquote>
<p>考虑pickle(cPickle在partucular中)和marshal。他们很快。但请记住,它们不是安全的或可扩展的,您需要为速度付出额外的责任。</p>