What are compressed and uncompressed files, how does it all work and why compressed files take less storage?

936 views

What are compressed and uncompressed files, how does it all work and why compressed files take less storage?

In: Technology

27 Answers

Anonymous 0 Comments

Just a fun example of compression.

I used the zen of python. For simplicity, I removed all punctuation and made it lower case.

I’m sure there are better ways to compress this as well.

Original: 807 bytes

>beautiful is better than ugly
>
>explicit is better than implicit
>
>simple is better than complex
>
>complex is better than complicated
>
>flat is better than nested
>
>sparse is better than dense
>
>readability counts
>
>special cases arent special enough to break the rules
>
>although practicality beats purity
>
>errors should never pass silently
>
>unless explicitly silenced
>
>in the face of ambiguity refuse the temptation to guess
>
>there should be one and preferably only one obvious way to do it
>
>although that way may not be obvious at first unless youre dutch
>
>now is better than never
>
>although never is often better than right now
>
>if the implementation is hard to explain its a bad idea
>
>if the implementation is easy to explain it may be a good idea
>
>namespaces are one honking great idea lets do more of those

Compressed generated with some code: 709 bytes

>[~=is;!=better;@=than;#=the;$=although;%=never;^=idea;&=complex;*=special;(=should;)=unless;{=obvious;}=it;|=implementation;=explain]
>
>beautiful ~ ! @ ugly
>
>explic} ~ ! @ implic}
>
>simple ~ ! @ &
>
>& ~ ! @ complicated
>
>flat ~ ! @ nested
>
>sparse ~ ! @ dense
>
>readabil}y counts
>
>* cases arent * enough to break # rules
>
>$ practical}y beats pur}y
>
>errors ( % pass silently
>
>) explic}ly silenced
>
>in # face of ambigu}y refuse # temptation to guess
>
>#re ( be one and preferably only one { way to do }
>
>$ that way may not be { at first ) youre dutch
>
>now ~ ! @ %
>
>$ % ~ often ! @ right now
>
>if # | ~ hard to }s a bad ^
>
>if # | ~ easy to } may be a good ^
>
>namespaces are one honking great ^ lets do more of those

Compressed after manual modification: 673 bytes

>[~=is;!=better;@=than;#=the;$=although;%=never;^=idea;&=complex;*=special;(=should;)=unless;{=obvious;}=it;|=implementation;=explain;:= ~ ! @ ;’= # | ~ ;<= to }]
>
>beautiful:ugly
>
>explic}:implic}
>
>simple:&
>
>&:complicated
>
>flat:nested
>
>sparse:dense
>
>readabil}y counts
>
>* cases arent * enough to break # rules
>
>$ practical}y beats pur}y
>
>errors ( % pass silently
>
>) explic}ly silenced
>
>in # face of ambigu}y refuse # temptation to guess
>
>#re ( be one and preferably only one { way to do }
>
>$ that way may not be { at first ) youre dutch
>
>now:%
>
>$ % ~ often ! @ right now
>
>if’hard<s a bad ^
>
>if’easy< may be a good ^
>
>namespaces are one honking great ^ lets do more of those

Edit: Dang reddit messed up my formatting. Should be fixed now

You are viewing 1 out of 27 answers, click here to view all answers.