New Features in Python 1.6

Fredrik Lundh effbot at telia.com
Tue Apr 4 13:40:54 EDT 2000


François Pinard wrote:
> Beware.  It might be patented already...  Let's see.  Does it work this
way?
>
> * If the file is empty, you're done.
> * If the file holds a single bit, you're done.
> * Split the whole file into pairs of sequences, the first part of the pair
>   being an eager, but possibly empty sequence of consecutive zero-bits,
>   the second part being an eager, but possibly empty sequence of
consecutive
>   one-bits.  Notice that there is only one way to do this split.
> * Replace each sequence above by the count of bits it contains, expressed
>   directly as a binary number for the first count of the pair, and as the
>   one-complements of the binary number for the second count of the pair.
>   Notice that given these counts, it is trivial to rebuild the contents
>   of the previous step.
> * Iterate.

why not just use two different compression algorithms repeatedly,
until you've squeezed the file down to a suitable size?  it takes a
little work, but you can design them so that one of them can always
strip away at least one bit from the input stream.

by reversing this process in the right order, you can easily reconstruct
the original data stream.

a much faster version, known as "blom compression" after it's inventor,
uses 256 algorithms...

</F>





More information about the Python-list mailing list