Is there a way to do the following efficiently?

An example class:

- Code: Select all
`cdef class ClassWithAdditionFunction:`

cdef double value

def __init__(self, double value):

self.value = value

cpdef add_one(self):

self.value += 1

A slow function:

- Code: Select all
`cdef unsigned long int i, ii`

cdef unsigned long int loops = pow(10, 8)

cdef double value

addition_classes = np.array([None] * 10)

for i in range(len(addition_classes)):

addition_classes[i] = ClassWithAdditionFunction(value=0)

for i in range(loops/10):

for ii in range(10):

addition_classes[ii].add_one()

Thank you very much for any suggestions!