Page 1 of 1

Alternative code emitters and generators

Posted: Tue Aug 19, 2014 3:49 pm
by pythoncoder
Is there any way to apply the alternative code emitters to generators? I'm using generators to implement lightweight threads and there's a potential performance benefit in using these but my tests so far have failed. The following issues a "TypeError: 'NoneType' object is not an iterator" on the print line unless I comment out the decorator.

Code: Select all

@micropython.native
def myfunc():
    for x in range(10):
        yield 2*x

gen = myfunc()
while True:
    try:
        print(next(gen))
    except StopIteration:
        break
Regards, Pete