Code: Select all
class stem:
def flush(self):
self.write(self, <blah>)
class Dumper(stem):
def write(self, bb):
print("---> WRITE called", bb)
What I am trying to do is implement class stem as a MicroPython native module, for speed.
My question is, how does the C implementation of flush() find the method named write? I have so far failed to find an example of this in the existing code base. My attempts to implement it from scratch also didn't work.
What I have done as a hacky workaround is to implement a register method in stem which stores the write function as a callable. So the Python side looks like this:
Code: Select all
f = Dumper()
f.register(f.write)
https://github.com/jamesbowman/py-bteve ... mpy/stem.c
This works fine, but it would be much better to do this properly.
Any pointers much appreciated, thanks.