Hi!
Try umachine.time_ms()
Hi!
Try umachine.time_ms()
its time_ms
Thanks guys. That works. Finally I can make use of time
That doesnât mean the framerate counter is necessarily inaccurate,
youâd expect to have different running speeds for the simulator, the emulator and the actual hardware because theyâre all different mechanisms and itâs probably not possible to get them that close to each other.
The value on hardware is the one thatâs actually important.
(Although this does imply that maybe the frame rate limitation system might not be that accurate.)
I have now updated the FAQ and the uMachine reference with time_ms() info.
hi Guys
I wondering where can I find the filter/reduce functions in pokitto micropython? @Hanski
it complains like âfilter is undefinedââŚ
Just in case it doesnât provide them, these should be valid implementations:
def filter(function, iterable):
for item in iterable:
if function(item):
yield item;
def reduce(function, iterable):
accumulator = None
for item in iterable:
# Probably breaks if an iterable returns None
if previous != None:
accumulator = function(accumulator, item);
else
accumulator = item
# Extra bonus?
def accumulate(function, iterable):
previous = None
for item in iterable:
# Probably breaks if an iterable returns None
if previous != None:
yield function(previous, item);
previous = item
# Bonus, because what's reduce without map? :P
def map(function, iterable):
for item in iterable:
yield function(item);
(They might be wrong - Iâm not really a Python programmer, I just cobbled these together from a few minutes on the internet.)
Edit: realised I accidentally implemented accumulate
instead of reduce
. (Iâm used to these functions having different names.) On the bright side, thatâs another bonus function.
Itâs worth noting that all these functions will be less efficient than versions implemented in the C++ layer.
hey, thank you for the quick response!
Micropython is a subset of Python so might well be that those functions are just not implemented in MP core.