compiling C modules into loadable shared objects
Re: compiling C modules into loadable shared objects
All true, but in this case (calling a MicroPython function like allocating a buffer) is already in the category of things that this feature handles well. In the QR example, the native module allocates the tuple to return the "pixel" data. There's a finite set of MicroPython internals that you need access to.
Re: compiling C modules into loadable shared objects
Beyond what @jimmo has already pointed out in his last post, the situation is really not worse then with pointers: if you pass a pointer to a function, it is the caller's responsibility to allocate the required amount of memory, otherwise, all hell might break loose. But no one would consider this error prone.
And, taking the original example of @OutoftheBOTS_, when you want someone to do your FFT, then you know in advance, how much data you are going to get back. And I think, the kind of computations we are talking about all fall into such a category.
Re: compiling C modules into loadable shared objects
Depends on whom you ask, one can always find (misinformed) people who consider C and raw pointer access the worst of all evils. Which likely stems from the amounts of bugs caused by it. But in any case my point was rather that it's more error prone than alternatives.
Well, you know that when you implement the function. Or else if you're targetting an experienced user than then he/she also can figure out. But someone new to FFT might have to read the documentation first and/or might make the mistake of passing something of an incorrect size. I can't even count the questions I saw on StackOverflow and similar caused by things like this. Now don't get me wrong, in code where it matters I use preallocation constantly but all in all it's more user-friendly to have less coupling..And, taking the original example of @OutoftheBOTS_, when you want someone to do your FFT, then you know in advance, how much data you are going to get back.
Re: compiling C modules into loadable shared objects
Sorry for not reading previous pages and watching video but just in case, you can load any module with FFI on unix port written in any compiled language and you can even import quite complex C++ classes as MicroPython objects proxies.
using stock micropython + pfalcon tools + c2ffi on C header only since forever :
https://github.com/pmp-p/micropython-ffigen
using stock micropython + a Panda3D tool called interrogate on C++ headers + *source* since recently:
https://github.com/pmp-p/panda3d-interrogator
also for tech help you could ask straight on https://kiwi.freenode.net/?nick=mp_foru ... icropython and wait for an answer or here https://gitter.im/micropython/Lobby
using stock micropython + pfalcon tools + c2ffi on C header only since forever :
https://github.com/pmp-p/micropython-ffigen
using stock micropython + a Panda3D tool called interrogate on C++ headers + *source* since recently:
https://github.com/pmp-p/panda3d-interrogator
also for tech help you could ask straight on https://kiwi.freenode.net/?nick=mp_foru ... icropython and wait for an answer or here https://gitter.im/micropython/Lobby