Is there a character that never appears in the output of zlib.compress?
Cameron Simpson
cs at cskk.id.au
Wed Jan 29 05:25:37 EST 2020
On 28Jan2020 23:09, Peng Yu <pengyu.ut at gmail.com> wrote:
>I'd like to tell what part is zlib.compress data in an input stream.
>One way is to use some characters that never appear in zlib.compress
>output to denote the boundary. Are there such characters? Thanks.
If you mean: is there a byte which never appears, then apparently not:
[~]fleet*1> python3 testzlib.py
........
where testzlib.py contains this code:
from random import randint
import sys
from zlib import compress
unseen = set(range(256))
while unseen:
sys.stdout.write('.')
sys.stdout.flush()
block = bytes(randint(0,255) for _ in range(256))
cdata = compress(block)
for c in cdata:
unseen.discard(c)
sys.stdout.write('\n')
More information about the Python-list
mailing list