Message6576

Author pekka.klarck
Recipients pekka.klarck
Date 2011-07-22.07:30:21
SpamBayes Score 0.00012152548
Marked as misclassified No
Message-id <1311319822.25.0.58288119205.issue1775@psf.upfronthosting.co.za>
In-reply-to
Content
For anyone interested, below is our compress implementation. It's not fully generic (i.e. doesn't allow setting compression level) but works great for us.


from java.util.zip import Deflater
import jarray

DEFLATOR = Deflater(9, False)

def compress(text):
    DEFLATOR.setInput(text)
    DEFLATOR.finish()
    buf = jarray.zeros(1024, 'b')
    compressed = []
    while not DEFLATOR.finished():
        length = DEFLATOR.deflate(buf, 0, 1024)
        compressed.append(buf[:length].tostring())
    DEFLATOR.reset()
    return ''.join(compressed)
History
Date User Action Args
2011-07-22 07:30:22pekka.klarcksetmessageid: <1311319822.25.0.58288119205.issue1775@psf.upfronthosting.co.za>
2011-07-22 07:30:22pekka.klarcksetrecipients: + pekka.klarck
2011-07-22 07:30:22pekka.klarcklinkissue1775 messages
2011-07-22 07:30:21pekka.klarckcreate