Q:

How modify a class attribute through a reference of it in njit function?

I would like to update a class attribute inside a njit function but i dond't know the variable name in advance.  To illustrate that, I made the below code
from numba import jitclass, jit, njit
from numba import int32, float64
import numpy as np

spec = [('A' ,float64),
        ('B' ,float64)]

@jitclass(spec, )
class myClass():
    def __init__(self):
        self.A = 1.
        self.B = 1.
    def add_A_and_B(self):
        return self.A + self.B

class essai():
    def __init__(self):
        self.C = myClass()

    def compute(self):
        mystring = 'C.A' # parameter that I want update
        nameclass, nameparam = mystring.split('.') # get the class name and the variable to update
        tp = np.linspace(0, 100, num = 101)
        val_A = np.linspace(0, 100, num = 101)
        ref = getattr(getattr(self,nameclass),nameparam) # Doesn't work, trying to get a reference to a class attribute C.A
        y= solve1(self.C,tp,ref,val_A) # pass the reference to the njit function to update C.A in the njit function
        print(y)

@njit(fastmath=True)
def solve1(C,tp,param,paramvalues):
    y = np.zeros(len(tp), )
    for idx, t in enumerate(tp):
        param=paramvalues[idx]
        #C.A=paramvalues[idx] # what I expect the previous line to do
        y[idx] = C.add_A_and_B()
    return y

E=essai()
E.compute()

The variable I want to update is mystring = 'C.A' but in my complete code, this come from a user input. So what I seeking to do is get a reference of that variable, I tried ref = getattr(getattr(self,nameclass),nameparam) but that doesn't work. once I will have this reference I will be able to pass it to the solve1 njit function in order to update C.A inside the njit function.
So I I run the code I get 
[ 2.  2.  2.  2.  2.  2.

instead of 
[   1.    2.    3.    4.    5. .... 

If I use C.A=paramvalues[idx]in the solve1function.
So the question is how do I update the attribute A of C inside a njitfunction by using a string which contains the name of the variable I would like to update (in my case mystring = 'C.A')

A:

1) references, as you want to be able to use it here by assigning directly to it  (param=...) don't exist in python.  Assigning to an lvalue with no dot or [] modifier always rebinds that name, whether in numba or not.  Edit: to clarify, not true if the name was marked with a global (to a global variable) or nonlocal (to a closed over variable), but neither apply here.
2) in nopython mode, numba needs to know at compile time which attribute you are assigning to (it's in essence calculating offsets into a c struct), so I think the best you'll be able to do is compile two versions of the function.

