Yes, refcounting is the issue.
> (what about atomic integers then?)
Should CPython choose to adopt them, that would solve this issue.
> Nuclide cannot be easily converted to C/C++
> type - contains methods intended to be callable from Python space.
>
> I've also tried to use libcpp.list as a container, but this isn't probably
> supposed to work with extension types and crashes the Cython compiler. (and
> would solve just the part of my problem)
Yeah, you'll have refounting issues trying to do that too.
What you really want is a borrowed reference, but we haven't yet
figured out the best way to add that to Cython. (It's both a question
of syntax and making it hard for the user to shoot themselves in the
foot.) You could do things with NumPy arrays, but even easier is to do
from cpython.list cimport PyList_GET_ITEM
cdef list nuclides = [...]
with nogil:
for i in range(10):
compute_nuclide(<Nuclide>nuclides[i]), param)
You can also do (again, unteseted)
cdef compute_all_nuclides(double param) with gil:
cdef Nuclide nuclide
with nogil:
for i in range(nuclides.shape[0]):
with gil:
nuclide = nuclides[i]
compute_nuclide(nuclide, param)
- Robert