Skip to content

Commit cb7041f

Browse files
committed
Create separate C and python interface for better docs building
1 parent f1b21a2 commit cb7041f

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

src/isal/igzip_lib.pxd

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# SOFTWARE.
2020

2121
# cython: language_level=3
22+
# cython: binding=True
2223

2324
cdef extern from "<isa-l/igzip_lib.h>":
2425
# Deflate compression standard defines
@@ -492,16 +493,16 @@ cdef:
492493

493494
cdef int mem_level_to_bufsize(int compression_level, int mem_level, unsigned int *bufsize)
494495

495-
cpdef compress(data,
496-
int level= ?,
497-
int flag = ?,
498-
int mem_level = ?,
499-
int hist_bits = ?,
496+
cdef _compress(data,
497+
int level,
498+
int flag,
499+
int mem_level,
500+
int hist_bits,
500501
)
501502

502-
cpdef decompress(data,
503-
int flag = ?,
504-
int hist_bits= ?,
505-
Py_ssize_t bufsize= ?)
503+
cdef _decompress(data,
504+
int flag,
505+
int hist_bits,
506+
Py_ssize_t bufsize)
506507

507508
cdef bytes view_bitbuffer(inflate_state * stream)

src/isal/igzip_lib.pyx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ cdef void arrange_input_buffer(stream_or_state *stream, Py_ssize_t *remains):
168168
stream.avail_in = <unsigned int>py_ssize_t_min(remains[0], UINT32_MAX)
169169
remains[0] -= stream.avail_in
170170

171-
cpdef compress(data,
171+
def compress(data,
172172
int level=ISAL_DEFAULT_COMPRESSION_I,
173173
int flag = IGZIP_DEFLATE,
174174
int mem_level = MEM_LEVEL_DEFAULT_I,
@@ -196,6 +196,15 @@ cpdef compress(data,
196196
hist_bits is not used to set the compression flag.
197197
This is best left at the default (15, maximum).
198198
"""
199+
return _compress(data, level, flag, mem_level, hist_bits)
200+
201+
202+
cdef _compress(data,
203+
int level,
204+
int flag,
205+
int mem_level,
206+
int hist_bits,
207+
):
199208
# Initialise stream
200209
cdef isal_zstream stream
201210
cdef unsigned int level_buf_size
@@ -252,7 +261,7 @@ cpdef compress(data,
252261
PyMem_Free(obuf)
253262

254263

255-
cpdef decompress(data,
264+
def decompress(data,
256265
int flag = ISAL_DEFLATE,
257266
int hist_bits=ISAL_DEF_MAX_HIST_BITS,
258267
Py_ssize_t bufsize=DEF_BUF_SIZE):
@@ -274,6 +283,13 @@ cpdef decompress(data,
274283
larger buffer will improve performance by negating the
275284
costs associated with the dynamic resizing.
276285
"""
286+
return _decompress(data, flag, hist_bits, bufsize)
287+
288+
289+
cdef _decompress(data,
290+
int flag,
291+
int hist_bits,
292+
Py_ssize_t bufsize):
277293
if bufsize < 0:
278294
raise ValueError("bufsize must be non-negative")
279295

src/isal/isal_zlib.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ from .igzip_lib cimport(
8585
view_bitbuffer,)
8686

8787
# Alias igzip_lib compress and decompress functions
88-
from .igzip_lib cimport compress as igzip_compress
89-
from .igzip_lib cimport decompress as igzip_decompress
88+
from .igzip_lib cimport _compress as igzip_compress
89+
from .igzip_lib cimport _decompress as igzip_decompress
9090

9191
from . import igzip_lib
9292
from libc.stdint cimport UINT64_MAX, UINT32_MAX

0 commit comments

Comments
 (0)