You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import time
def ret(arg):
yield None
def test(klass=int, count=10000):
for n in range(count):
ret(klass())
def measure(what, name):
start = time.ticks_ms()
for _ in range(10):
what()
end = time.ticks_ms()
print(name, time.ticks_diff(end, start))
for typ in [int, float, dict, list]:
measure(lambda: test(typ), typ)
Which yields numbers like this on windows and unix ports and reportedly does the same on RP2/pico:
It looks like this has to do with the GC doing excessive work to find some memory to create the generator (calling ret). If klass() allocates memory then it's fast. If it doesn't allocate memory then it's slow.
Originally reported here: https://forum.micropython.org/viewtopic.php?f=2&t=12060; 'seemingly' because I'm not sure what exactly is slow. Reproduce with:
Which yields numbers like this on windows and unix ports and reportedly does the same on RP2/pico:
Given the extreme difference this seems to indicate an underlying problem.
The text was updated successfully, but these errors were encountered: