Skip to content

Commit 550e010

Browse files
committed
Use meth_fastcall for compress_and_crc
1 parent 1107f47 commit 550e010

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/isal/isal_zlibmodule.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,27 @@ PyDoc_STRVAR(ParallelCompress_compress_and_crc__doc__,
372372
#define PARALLELCOMPRESS_COMPRESS_AND_CRC_METHODDEF \
373373
{ \
374374
"compress_and_crc", (PyCFunction)ParallelCompress_compress_and_crc, \
375-
METH_VARARGS, ParallelCompress_compress_and_crc__doc__}
375+
METH_FASTCALL, ParallelCompress_compress_and_crc__doc__}
376376

377377
static PyObject *
378-
ParallelCompress_compress_and_crc(ParallelCompress *self, PyObject *args)
378+
ParallelCompress_compress_and_crc(ParallelCompress *self,
379+
PyObject *const *args,
380+
Py_ssize_t nargs)
379381
{
382+
if (nargs != 2) {
383+
PyErr_Format(
384+
PyExc_TypeError,
385+
"compress_and_crc takes exactly 2 arguments, got %zd",
386+
nargs);
387+
return NULL;
388+
}
380389
Py_buffer data;
381390
Py_buffer zdict;
382-
static char *format = "y*y*:compress_and_crc";
383-
384-
if (PyArg_ParseTuple(args, format, &data, &zdict) < 0) {
391+
if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) == -1) {
392+
return NULL;
393+
}
394+
if (PyObject_GetBuffer(args[1], &zdict, PyBUF_SIMPLE) == -1) {
395+
PyBuffer_Release(&data);
385396
return NULL;
386397
}
387398

0 commit comments

Comments
 (0)