Skip to content

Implement zlib module#1243

Merged
windelbouwman merged 4 commits into
RustPython:masterfrom
mpajkowski:zlib_module
Aug 13, 2019
Merged

Implement zlib module#1243
windelbouwman merged 4 commits into
RustPython:masterfrom
mpajkowski:zlib_module

Conversation

@mpajkowski
Copy link
Copy Markdown
Contributor

@mpajkowski mpajkowski commented Aug 12, 2019

Hello, I implemented following methods from zlib module:

  • zlib.compress
  • zlib.decompress
  • zlib.crc32
  • zlib.adler32

+ Implement following functions:
  * zlib.compress
  * zlib.decompress
  * zlib.crc32
  * zlib.adler32

+ Add compression level constants
@mpajkowski mpajkowski changed the title Zlib module Implement zlib module Aug 12, 2019
Comment thread vm/src/stdlib/zlib.rs Outdated
};
}

checksum_fn!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The macro is used twice, so I would suggest to simply write out the two methods for readability. It's about the same amount on lines, but is somewhat easier to read. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, at the first time i had done it with PyFuncArgs and arg_check! - it was much longer then. I'll rewrite it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, done! 😃

Get rid of checksum_fn macro
for text in compressed_lorem_list:
assert zlib.decompress(text) == lorem

assert_raises(zlib.error, lambda: zlib.compress(b"123", -40))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a minor though, I find this

with assertRaises(zlib.error):
    zlib.compress(b"123", -40)

somewhat easier to read. What do you think?

@windelbouwman windelbouwman merged commit e0431c0 into RustPython:master Aug 13, 2019
@mpajkowski mpajkowski deleted the zlib_module branch August 13, 2019 21:50
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.

2 participants