miurahr / pyppmd

pyppmd provides classes and functions for compressing and decompressing text data, using PPM (Prediction by partial matching) compression algorithm variation H and I.2. It provide an API similar to Python's zlib/bz2/lzma modules.
https://pyppmd.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
8 stars 3 forks source link

Add restore_method kwargs #24

Closed cielavenir closed 3 years ago

cielavenir commented 3 years ago

there would be demand to select the restore method from restart and cutoff.

miurahr commented 3 years ago

Thank you for the proposal.

It is better and Pythonic way to provide constant symbol for restore_mode parameter.

for example in CPython extension

PyModule_AddIntConstant(module, "PPMD_RESTART", 0);

in PyInit_ppmd() function. https://github.com/miurahr/pyppmd/blob/main/src/ext/_ppmdmodule.c#L1890

and also does similar for cffi , then export constants as _all_ = (... "PPMD_RESTART" ..) in __init__.py

cielavenir commented 3 years ago

done, but let me make this WIP

cielavenir commented 3 years ago

unwiped; please take a look after #28 is solved

cielavenir commented 3 years ago

minor: too many commits, might need to squash after #33 is merged

miurahr commented 3 years ago

minor: too many commits, might need to squash after #33 is merged

I'll use squash-merge on github.

cielavenir commented 3 years ago

@miurahr oh why this branch has many conflicts now?

cielavenir commented 3 years ago

Pretty not sure what you did to my branch, but in my cielavenir@cafe30a5a7b57a549f1451669e75348bb5a804d2 (which is based on https://github.com/miurahr/pyppmd/pull/33#issuecomment-894763993 ) tests are passing also in Pypy3.

*****@debian:~/devel/pyppmd$ PYTHONPATH= /usr/bin/pypy3 -m pytest tests -v
========================================================================= test session starts ==========================================================================
platform linux -- Python 3.7.10[pypy-7.3.5-final], pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/pypy3
cachedir: .pytest_cache
benchmark: 3.4.1 (defaults: timer=pytest_benchmark.timers.monotonic disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=True warmup_iterations=100000)
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/*****/devel/pyppmd/.hypothesis/examples')
rootdir: /home/*****/devel/pyppmd, configfile: tox.ini
plugins: benchmark-3.4.1, hypothesis-6.14.6
collected 25 items                                                                                                                                                     

tests/test_benchmark.py::test_benchmark_text_compress[PPMd H-7-6-16777216] PASSED                                                                                [  4%]
tests/test_benchmark.py::test_benchmark_text_compress[PPMd I-8-8-8388608] PASSED                                                                                 [  8%]
tests/test_benchmark.py::test_benchmark_text_decompress[PPMd H-7-6-16777216] PASSED                                                                              [ 12%]
tests/test_benchmark.py::test_benchmark_text_decompress[PPMd I-8-8-8388608] PASSED                                                                               [ 16%]
tests/test_fuzzer.py::test_ppmd7_fuzzer PASSED                                                                                                                   [ 20%]
tests/test_fuzzer.py::test_ppmd8_fuzzer PASSED                                                                                                                   [ 24%]
tests/test_highlevel_api.py::test_compress_str PASSED                                                                                                            [ 28%]
tests/test_highlevel_api.py::test_compress PASSED                                                                                                                [ 32%]
tests/test_highlevel_api.py::test_decompress_str PASSED                                                                                                          [ 36%]
tests/test_highlevel_api.py::test_decompress PASSED                                                                                                              [ 40%]
tests/test_ppmd7.py::test_ppmd7_encoder PASSED                                                                                                                   [ 44%]
tests/test_ppmd7.py::test_ppmd7_encoder2 PASSED                                                                                                                  [ 48%]
tests/test_ppmd7.py::test_ppmd7_decoder PASSED                                                                                                                   [ 52%]
tests/test_ppmd7.py::test_ppmd7_decoder2 PASSED                                                                                                                  [ 56%]
tests/test_ppmd7.py::test_ppmd7_encode_decode[16777216] PASSED                                                                                                   [ 60%]
tests/test_ppmd7.py::test_ppmd7_encode_decode[1048576] PASSED                                                                                                    [ 64%]
tests/test_ppmd8.py::test_ppmd8_encoder1 PASSED                                                                                                                  [ 68%]
tests/test_ppmd8.py::test_ppmd8_encoder2 PASSED                                                                                                                  [ 72%]
tests/test_ppmd8.py::test_ppmd8_decoder1 PASSED                                                                                                                  [ 76%]
tests/test_ppmd8.py::test_ppmd8_decoder2 PASSED                                                                                                                  [ 80%]
tests/test_ppmd8.py::test_ppmd8_encode_decode[8388608-0] PASSED                                                                                                  [ 84%]
tests/test_ppmd8.py::test_ppmd8_encode_decode[8388608-1] PASSED                                                                                                  [ 88%]
tests/test_ppmd8.py::test_ppmd8_encode_decode[1048576-0] PASSED                                                                                                  [ 92%]
tests/test_ppmd8.py::test_ppmd8_encode_decode[1048576-1] PASSED                                                                                                  [ 96%]
tests/test_ppmd8.py::test_ppmd8_encode_decode2[\x00-2-2048] PASSED                                                                                               [100%]
cielavenir commented 3 years ago

for now I decided to change the package name of my pyppmd distribution to avoid confusion......

miurahr commented 3 years ago

OK, I'd like to revert #33 in main and merge your tree HEAD of "Fix test on CFFI" 43791a5 into main.

miurahr commented 3 years ago

Now merged.