Skip to content

Commit 5270039

Browse files
committed
Start on module documentation
1 parent 78ab6b5 commit 5270039

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

src/isal/igzip_lib.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ cpdef compress(data,
500500
)
501501

502502
cpdef decompress(data,
503-
unsigned int flag = ?,
504-
unsigned int hist_bits= ?,
505-
Py_ssize_t bufsize= ?)
503+
int flag = ?,
504+
int hist_bits= ?,
505+
Py_ssize_t bufsize= ?)
506506

507507
cdef bytes view_bitbuffer(inflate_state * stream)

src/isal/igzip_lib.pyx

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ from cpython.bytes cimport PyBytes_FromStringAndSize
2929
cdef extern from "<Python.h>":
3030
const Py_ssize_t PY_SSIZE_T_MAX
3131

32+
"""
33+
Pythonic interface to ISA-L's igzip_lib.
34+
35+
This module comes with the following constants:
36+
============================== ================================================
37+
Constant Meaning
38+
============================== ================================================
39+
``ISAL_BEST_SPEED`` The lowest compression level (0)
40+
``ISAL_BEST_COMPRESSION`` The highest compression level (3)
41+
``ISAL_DEFAULT_COMPRESSION`` The compromise compression level (2)
42+
``DEF_BUF_SIZE`` Default size for the starting buffer (16K)
43+
``MAX_HIST_BITS`` Maximum window size bits (15).
44+
``COMP_DEFLATE`` Flag to compress to a raw deflate block
45+
``COMP_GZIP`` Flag to compress a gzip block, consisting of a
46+
gzip header, raw deflate block and a gzip
47+
trailer.
48+
``COMP_GZIP_NO_HDR`` Compress
49+
"""
3250
ISAL_BEST_SPEED = ISAL_DEF_MIN_LEVEL
3351
ISAL_BEST_COMPRESSION = ISAL_DEF_MAX_LEVEL
3452
cdef int ISAL_DEFAULT_COMPRESSION_I = 2
@@ -135,6 +153,19 @@ cpdef compress(data,
135153
compression (NOT no compression as in stdlib zlib!) and the
136154
fastest. 3 is the best compression and the slowest. Default
137155
is a compromise at level 2.
156+
:param flag: Controls the header and trailer. Can be any of: COMP_DEFLATE
157+
(default), COMP_GZIP, COMP_GZIP_NO_HDR, COMP_ZLIB,
158+
COMP_ZLIB_NO_HDR.
159+
:param mem_level: Set the memory level for the memory buffer. Larger
160+
buffers improve performance. Can be any of:
161+
MEM_LEVEL_DEFAULT (default,
162+
equivalent to MEM_LEVEL_LARGE), MEM_LEVEL_MIN,
163+
MEM_LEVEL_SMALL, MEM_LEVEL_MEDIUM, MEM_LEVEL_LARGE,
164+
MEM_LEVEL_EXTRA_LARGE.
165+
:param hist_bits: Sets the size of the view window. The size equals
166+
2^hist_bits. Similar to zlib wbits value, except that
167+
hist_bits is not used to set the compression flag.
168+
This is best left at the default (15, maximum).
138169
"""
139170
# Initialise stream
140171
cdef isal_zstream stream
@@ -193,14 +224,26 @@ cpdef compress(data,
193224

194225

195226
cpdef decompress(data,
196-
unsigned int flag = ISAL_DEFLATE,
197-
unsigned int hist_bits=ISAL_DEF_MAX_HIST_BITS,
198-
Py_ssize_t bufsize=DEF_BUF_SIZE):
227+
int flag = ISAL_DEFLATE,
228+
int hist_bits=ISAL_DEF_MAX_HIST_BITS,
229+
Py_ssize_t bufsize=DEF_BUF_SIZE):
199230
"""
200231
Deompresses the bytes in *data*. Returns a bytes object with the
201232
decompressed data.
202233
203-
:param bufsize: The initial size of the output buffer.
234+
:param flag: Whether the compressed block contains headers and/or trailers
235+
and of which type. Can be any of: DECOMP_DEFLATE (default),
236+
DECOMP_GZIP, DECOMP_GZIP_NO_HDR, DECOMP_GZIP_NO_HDR_VER,
237+
DECOMP_ZLIB, DECOMP_ZLIB_NO_HDR, DECOMP_ZLIB_NO_HDR_VER.
238+
:param hist_bits: Sets the size of the view window. The size equals
239+
2^hist_bits. Similar to zlib wbits value, except that
240+
hist_bits is not used to set the compression flag.
241+
This is best left at the default (15, maximum).
242+
:param bufsize: The initial size of the output buffer. The output buffer
243+
is dynamically resized according to the need. The default
244+
size is 16K. If a larger output is expected, using a
245+
larger buffer will improve performance by negating the
246+
costs associated with the dynamic resizing.
204247
"""
205248
if bufsize < 0:
206249
raise ValueError("bufsize must be non-negative")

0 commit comments

Comments
 (0)