3 ms·
Both hex and ascii85 will align at 1024 byte boundaries, base64 will align at 1024*3 bytes, so you'll end up with a symbol stream something like this: symbol_1
by hackcasual 9y ago
Both hex and ascii85 will align at 1024 byte boundaries, base64 will align at 1024*3 bytes, so you'll end up with a symbol stream something like this:
symbol_1, symbol_2, symbol_3, ptr_to_1, ptr_to_2,...
ascii85 performs better than hex simply because it's dictionary is shorter.
If you compress something with a bit more structure, like "Hamlet", you'll get this:
>>> import urllib.request,zlib,codecs,base64
>>> hamlet = urllib.request.urlopen("http://www.gutenberg.org/cache/epub/2265/pg2265.txt").read()
>>> len(codecs.encode(hamlet, 'base64'))
248577
>>> len(codecs.encode(hamlet, 'hex'))
368018
>>> len(base64.a85encode(hamlet))
230012
>>> len(zlib.compress(codecs.encode(hamlet, 'base64')))
102788
>>> len(zlib.compress(codecs.encode(hamlet, 'hex')))
88827
>>> len(zlib.compress(base64.a85encode(hamlet)))
121364