Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: Compression Date: Thu, 14 Jul 2016 10:59:05 +0200 Organization: None Lines: 20 Message-ID: References: <57874a72$0$2910$c3e8da3$76491128@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de buociqBClNMlRfDC74u0sQn1+mQ7/calQ9e4CT3pgpHg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'redundancy': 0.16; 'wrote:': 0.16; 'string': 0.17; '>>>': 0.20; "skip:' 40": 0.22; 'space.': 0.22; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'skip:m 30': 0.27; 'quarter': 0.29; 'random': 0.29; "d'aprano": 0.33; 'steven': 0.33; 'saved': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'received:org': 0.37; 'skip:5 10': 0.37; 'data': 0.39; "didn't": 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd80d0.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <57874a72$0$2910$c3e8da3$76491128@news.astraweb.com> Xref: csiph.com comp.lang.python:111435 Steven D'Aprano wrote: > How about some really random data? > > py> import string > py> data = ''.join(random.choice(string.ascii_letters) for i in > range(21000)) py> len(codecs.encode(data, 'bz2')) > 15220 > > That's actually better than I expected: it's found some redundancy and > saved about a quarter of the space. It didn't find any redundancy, it found the two unused bits: >>> math.log(len(string.ascii_letters), 2) 5.700439718141093 >>> 21000./8*_ 14963.654260120367