Reputation: 31948
I have some code that is ripe for simple parallelizing. However, it uses a C library. How do I define functions in pxd files as nogil? They are pure C so I do not see the problem...
This is the error message I get:
Error compiling Cython file:
------------------------------------------------------------
...
it = NULL
output[nfound] = indexes[i]
nfound += 1
i += 1
cn.free_interval_iterator(it_alloc)
^
------------------------------------------------------------
ncls/src/ncls.pyx:545:37: Calling gil-requiring function not allowed without gil
This is an example of the definitions in my pxd file:
int free_interval_iterator(IntervalIterator *it)
IntervalIterator *reset_interval_iterator(IntervalIterator *it)
int find_intervals(IntervalIterator *it0,
int start,
int end,
IntervalMap im[],
int n,
SublistHeader subheader[],
int nlists,
IntervalMap buf[],
int nbuf,
int *p_nreturn,
IntervalIterator **it_return)
Upvotes: 0
Views: 161
Reputation: 31948
The correct way to do it is after the function definition.
IntervalIterator *interval_iterator_alloc() nogil
Upvotes: 1