robertu94 / libpressio

A library to abstract between different lossless and lossy compressors
Other
30 stars 11 forks source link

Is there an example of how to use the low level python bindings? #24

Closed ghost closed 2 years ago

ghost commented 2 years ago

Is there an example of how to use the low level python bindings?

robertu94 commented 2 years ago

Why do you want to use the lower level bindings? (just want to understand). From my experience the performance differences are modest between the high level and low level bindings if they aren't called in a tight loop, and they are a fair bit harder to use.

You can find an example here: https://github.com/robertu94/libpressio/blob/master/test/test_python.py

ghost commented 2 years ago

because i want to use libpressio in a conda env,thanks

robertu94 commented 2 years ago

@nihao-spec the high level bindings should be installed too when the low level binding are.

libpressio is the high level binding.

pressio is the low level one.

ghost commented 2 years ago

When I run

Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pressio
>>> library = pressio.instance()
>>> compressor = pressio.get_compressor(library, b"sz")
>>> sz_options = pressio.compressor_get_options(compressor)

I got that Segmentation fault (core dumped)

robertu94 commented 2 years ago

You probably didn’t enable the SZ bindings. With ‘ -DLIBPRESSIO_HAS_SZ=ON’ when you configured LibPressio. The high level bindings would have thrown an exception that was interpretable. There isn’t an incompatibility between them and conda.

The low level bindings are very similar to the equivalent C code requiring you to check error codes and error messages manually. I would encourage you to read the documentation for the library to better understand the pre conditions if you insist on using the low level bindings.

LibPressio turns everything off by default to make it easier to build only what you need (and cut build times by 20 minutes to hours depending on what you didn’t enable and don’t need).

ghost commented 2 years ago

I see, Thank you!