jbalogh/django-pylibmc — pull request #24 by jamescarr (2014-09-09 15:51:15+00:00)
Title: Use cPickle+zlib (when applicable) to report the bytes sent in error messages

So we rolled my last patch out to production and realized a drastic mistake. Just calling str() will give us an incorrect reporting of bytes. We had values that were near 1mb and were getting a report that they were a mere 3801 bytes because of __str__ being called. ;-)

Unfortunately pylibmc has the code to serialize and compress embeded in a way that we cannot call them outside of pylibmc, so this code seeks to replicate it the best way possible to capture the accurate number of bytes sent.