You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@gamblor21 Some notes based on our experiences with this in MicroPython:
Implement decompressing data streams via the zlib.decompressobj style function like in CPython.
The API for {decompress,compress}obj seems backwards to how I imagine most people want to use this (i.e. reading/writing compressed data to a stream/socket/file). I'm not convinced there's any value in implementing these for a microcontroller target.
GzipFile provides a much better interface.
Unfortunately GzipFile does not provide anything other than gzip compression, and implicitly uses the highest possible value of the window size. So providing the useful functionality while matching CPython exactly seems impossible without some compromises.
Expand zlib with other functions like crc32 similar to PR #1274 was looking to do.
We already provide binascii.crc32 instead (and it appears that CircuitPython does too).
Fortunately zlib.crc32 and binascii.crc32 share the same method signature so it would be very easy to just add the existing method to the zlib globals dict.
Because we're looking at now providing our zlib module in Python, it can just forward the binascii version.
Expand for compression functionality. Compression does not exist in the used uzlib library.
See micropython#11879 (comment) in particular for details about Damien's lz77 compressor implementation that we've added to our fork of uzlib.
Implement the gzip CPython library (in CPython this is done in pure python so could be done the same).
Unfortunately I don't think this can be done efficiently with just the API provided by zlib.
...the zlib C module has been removed and replaced with a new MicroPython-specific deflate module and DeflateIO class that is optimised to provide efficient streaming compression and decompression. The zlib (and gzip) modules are now implemented in pure Python on top of the deflate module.
Here as a note for myself, or others that may take this on after CP merges with MP 1.21 but this may also result in a space savings by moving some functionality to a python library. (Also see jimmo's comment about that talks about this in more detail).
Issue to track improvements that can be done to the
zlib
library that now has preliminary support:zlib.decompressobj
style function like in CPython.zlib
with other functions likecrc32
similar to PR [Refactoring... WIP] Implement CPython-compatible gzip.decompress, restore uzlib. Enable both for atmel-samd #1274 was looking to do.uzlib
library.gzip
CPython library (in CPython this is done in pure python so could be done the same).The text was updated successfully, but these errors were encountered: