Actually on Python2 "(name)" is not interpreted as a single element tuple but as a parenthesized string, which is the same as the string itself, so it works the same. Antony 2015-07-25 11:18 GMT-07:00 Jun T. : > > 2015/07/25 12:37, Antony Lee wrote: > > so replacing > > > > local script='import sys, pydoc > > def f(p,m,d): > > if m.find(".") < 0: sys.stdout.write(m+"\n") > > pydoc.ModuleScanner().run(f)' > > > > by > > > > local script='import pkgutil > > for importer, name, ispkg in pkgutil.iter_modules(): print(name)' > > > > in _python_modules yields a big improvement in speed. > > Thanks. It is indeed *much* faster. > > Do you think using 'print(name)' is sufficiently portable? > It seems it works with Python 2.x, because it is interpreted > as a print statement with a single-element tuple '(name)'. >