accessing list dictionary from C

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
tecdroid
Posts: 27
Joined: Thu Apr 08, 2021 6:22 am

accessing list dictionary from C

Post by tecdroid » Thu Dec 09, 2021 4:27 pm

hi there,
I'm just wondering how mp lists and dicts are accessed from within C.
Background is that I want to accelerate some software by implementing native modules which is - to my mind - really an intersting thing but sadly not well described..

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: accessing list dictionary from C

Post by dhylands » Thu Dec 09, 2021 9:05 pm

They're described by this structure: https://github.com/micropython/micropyt ... .h#L31-L36

So basically a pointer to a contiguous array of mp_obj_t's, one for each element in the list. You can look at objlist.c for some functions which utilize the data structure.

v923z
Posts: 168
Joined: Mon Dec 28, 2015 6:19 pm

Re: accessing list dictionary from C

Post by v923z » Sun Jan 23, 2022 7:03 pm

tecdroid wrote:
Thu Dec 09, 2021 4:27 pm
hi there,
I'm just wondering how mp lists and dicts are accessed from within C.
Background is that I want to accelerate some software by implementing native modules which is - to my mind - really an intersting thing but sadly not well described..
A whole section is devoted to this subject here: https://micropython-usermod.readthedocs ... ds_11.html

tecdroid
Posts: 27
Joined: Thu Apr 08, 2021 6:22 am

Re: accessing list dictionary from C

Post by tecdroid » Wed Feb 02, 2022 5:16 pm

wow! this is definitely the documentation i've been looking for. :-D

Post Reply