Passing variables between C and Python
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: Passing variables between C and Python
Perhaps it would be helpful if you explained with a bit more detail what your usage scenario is and what you are trying to accomplish. Then we wouldn't have to talk in such general terms and maybe give more concrete help.
Re: Passing variables between C and Python
I want to pass a python list to my c callback:
I've been using mp_obj_new_bytearray() to go from a c array to a python list, but I would like to know what the function is to go from a python list to a c array.
Code: Select all
static mp_obj_t c_sample_call_callback(mp_obj_t mpOpcode, mp_obj_t mp_arg1, mp_obj_t mp_arg2)
Re: Passing variables between C and Python
A python list is just an mp_obj_t.
The C code would then call mp_obj_list_get to get the length of the list and a pointer to an array of mp_obj_t's for each element in the list.
The C code would then call mp_obj_list_get to get the length of the list and a pointer to an array of mp_obj_t's for each element in the list.