Skip to content

zlib: improve bytes handling - #9036

Merged
JelleZijlstra merged 2 commits into
python:masterfrom
sobolevn:bytes-zlib
Oct 30, 2022
Merged

zlib: improve bytes handling#9036
JelleZijlstra merged 2 commits into
python:masterfrom
sobolevn:bytes-zlib

Conversation

@sobolevn

Copy link
Copy Markdown
Member

compress

>>>importzlib>>>zlib.compress(bytearray(b'abc'))
b"x\x9cKLJ\x06\x00\x02M\x01'">>>zlib.compress(memoryview(b'abc'))
b"x\x9cKLJ\x06\x00\x02M\x01'"

decompress

>>>zlib.decompress(bytearray(b"x\x9cKLJ\x06\x00\x02M\x01'"))
b'abc'>>>zlib.decompress(memoryview(b"x\x9cKLJ\x06\x00\x02M\x01'"))
b'abc'

adler32

>>>zlib.adler32(bytearray(b''))
1>>>zlib.adler32(memoryview(b''))
1

crc32

>>>zlib.crc32(bytearray(b'123'))
2286445522>>>zlib.crc32(memoryview(b'123'))
2286445522

decompressobj and compressobj

>>>zlib.decompressobj(0, bytearray(b''))
<zlib.Decompressobjectat0x103b4b520>>>>zlib.decompressobj(0, memoryview(b''))
<zlib.Decompressobjectat0x103b4b5d0>>>>zlib.compressobj(zdict=bytearray(b''))
<zlib.Compressobjectat0x103b4b520>>>>zlib.compressobj(zdict=memoryview(b''))
<zlib.Compressobjectat0x103b4b5d0>

@sobolevnsobolevn mentioned this pull request Oct 29, 2022
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@hauntsaninjahauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@JelleZijlstraJelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed in the C code.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@sobolevn@JelleZijlstra@hauntsaninja