Hello everyone
I'm not happy with the speed of my AES implementation (i have to use my own and don't have the time, or knowledge of C to port it to C) so I've resorted to experimenting with the micropython.native code generator, but I'm having some issues.
So my main.py file imports the file Encryption, that file imports Subclasses_Encryption and i added the @micropython.native in some functions in subclasses. But now it's saying that a certain variable (its a matrix called S block) is not defined, while it worked without the @micropython.native.
I did it like this: https://github.com/smurfendrek123/slimm ... enative.py is that the right way to use micropython.native?
If you want the files that import this file, to try it for yourself, ask me and i'll put them all together in a folder.
Thanks
Issues with the micropython.native code generator
-
- Posts: 6
- Joined: Sat Dec 10, 2016 3:46 pm
-
- Posts: 6
- Joined: Sat Dec 10, 2016 3:46 pm
Re: Issues with the micropython.native code generator
I got a reply from the kind robert-hh on github, and this was his answer.
I will confirm later whether or not this works@micropython.native code functions seem not to see global symbols. I stumbled over that too. I do not know whether it's a bug. In my case, I just moved that variable into the function using it. That may be possible here too. Otherwise, you could try to supply s_blok and inv_s_block as function parameters.
-
- Posts: 6
- Joined: Sat Dec 10, 2016 3:46 pm
Re: Issues with the micropython.native code generator
Okay, i played around with the native code generator, and it seems that functions using @micropython.native can't use anything outside the function. If you want to call upon another function, you have to add it as an argument, and the same goes for variables.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Issues with the micropython.native code generator
Another approach is to define a class. The native and viper decorators work with methods, which can then access data via self.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.