Judging from the source, currently class method in micropython is not supported.
The underlying C struct of mp class instance only has .locals_dict.
Any plans to add support for class or static method?
This feature would be really useful for module developers.
Thanks.
[SOLVED] static/class method in micropython?
[SOLVED] static/class method in micropython?
Last edited by shawwwn on Tue Sep 11, 2018 8:14 am, edited 2 times in total.
Re: static/class method in micropython?
Actually class methods (assuming you mean methods inside a class decorated with @classmethod) are supported. Look at the mp_type_classmethod type.
Re: static/class method in micropython?
Nice. Thanks for pointing that out.
I am finding a way to implement static method in a python class written in C.
Any ideas how it can be done?
I am finding a way to implement static method in a python class written in C.
Any ideas how it can be done?
Re: static/class method in micropython?
Nvm. I found it.
Inside py/obj.h,
there is a macro called
which puts a staticmethod wrap onto a function.
Thanks for the help!
I'm closing this issue.
Inside py/obj.h,
there is a macro called
Code: Select all
MP_DEFINE_CONST_STATICMETHOD_OBJ
Thanks for the help!
I'm closing this issue.