Terry J. Reedy <tjre...@udel.edu> added the comment: from idlelib.pyparse import Parser import timeit code='def f():\n' print(timeit.timeit("statement", # for example "p=Parser(4,4)", globals = globals()))
statement microseconds Parser .1 # test timeit code Parser() 2.2 p.set_code('') 1.4 p.set_code(code) 1.8 '('.translate(map1) 1.5 or 2.2 depending on ParseMap Translate time is longer for real code and Parser() instance creation time must be well less than 1/10, maybe 1/100 of any answer time. If we don't reuse instances, though, set_code should be part of __init__ (and tests changed). Either change is low priority. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32880> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com