Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib: improve bytes handling #9036

Merged
merged 2 commits into from
Oct 30, 2022
Merged

Conversation

sobolevn
Copy link
Member

compress

>>> import zlib
>>> 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.Decompress object at 0x103b4b520>
>>> zlib.decompressobj(0, memoryview(b''))
<zlib.Decompress object at 0x103b4b5d0>

>>> zlib.compressobj(zdict=bytearray(b''))
<zlib.Compress object at 0x103b4b520>
>>> zlib.compressobj(zdict=memoryview(b''))
<zlib.Compress object at 0x103b4b5d0>

@github-actions
Copy link
Contributor

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

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

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 free to 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