> with nogil, parallel():
> for i in prange(N):
> for j in prange(km.BatchSize):
You usually only want one loop in a set of nested loops to be prange.
Typically the outer loop, but in this case it might be easier to
parallelize the inner loop.
> Error: updated_sigma[i] = np.std(sample)
> ^
> ------------------------------------------------------------
>
> Converting to Python object not allowed without gil
You've potentially got 2 problems here:
* I can't see a definition of updated_sigma so it's possible that
Cython's just treating it as a regular Python object (which you can't
use in a nogil block)
* np.std is a Python function call. It can't go in a nogil block.
Your options are:
1. parallelize the inner loop only instead and keep np.std outside the
nogil block. I don't know if there enough work in the inner loop to be
worthwhile.
2. write your own code for the standard deviation skipping the call to
np.std
3. Put the call to np.std inside a `with gil` block. It's fairly likely
enough of the work in inside np.std that this'll make the
parallelization pointless, but it's sometimes a useful approach when you
have a small section that needs the GIL.
4. Drop the parallelization and write the code using the GIL.