joeatwork / python-lzw

LZW compression in pure python
MIT License
46 stars 17 forks source link

lzw port to Python 3 #2

Closed johnpaulett closed 8 years ago

johnpaulett commented 8 years ago

Thanks for the library @joeatwork!

I've conducted a 2-step port of lzw 1) 2to3 conversion to Python 3, manually adjusting code to work with different iteration of bytes and int to bytes conversion. There is a single commit that represents the changes 2) Using the six module, support both Python 2.7 and Python 3.4 with a single code base. Had to use a few six helpers and unfortunately adjust the doctests to use a slightly different return pattern to avoid differences in Python 3' b'' vs Python 2's '' output.

All tests pass, including the slow tests. Also did a test of compressing a complex document using original code in python 2, saving the output to disk, then decompressing using the port under python 3.4

I added a few additional commits to add tox testing to allow for testing both Python 2 & 3 and small adjustments to the README and trove classifiers.

It is likely possible that Python 3.2/3.3 (and maybe 2.6) could also be supported, but I did not attempt. It is also likely that there are a number of optimizations that could be made.

This port works for my needs, please let me know if you need anything additional from me. Would love to update pypi with these commits.

joeatwork commented 8 years ago

Great stuff! Thanks for submitting this! I'll take a closer look at it over the weekend, and get this merged. I'd also love to hear about how you're using the library!

Thanks again!

joeatwork commented 8 years ago

Great! I've merged this work into master - thanks again for your contribution!

johnpaulett commented 8 years ago

@joeatwork thanks for reviewing and merging!

The library has been useful for decoding legacy text data that was compressed with lzw.