Cython class : iterate over cdef'ed members

asked 2020-04-03 20:13:52 +0200

Mika007 gravatar image

Dear all,

my question is in the title : for some reason it may be usefull to me to iterate over a cdef'ed class cdef'ed members. I inherit from sage.calculus.ode.ode_system for ODE computation.

   cdef class trapModelImporter(sage.calculus.ode.ode_system):
        cdef double ASi, NSi, AGe, NGe, AEr, NEr, BEr, C,BSi, PSi, BAl, PAl, g;

        def setParams(self,pdict):

All the members have default values and I want to customize some of them. The aim of this iteration through the members should be to associate a value from the "pdict" parameter of setParam. This parameter is intended to associate keys which names are Asi, NSi, etc, with their new value. I tried by generating a string and using "exec" but it did not work, i belive it coms from cython itself. I am not sure it is possible that way, but that seemed to be an efficient way to change only the wanted paremeters.

Is that possible ?

Regards, Mike

edit retag flag offensive close merge delete