Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Improvement to python module list generation used for command completion
2015/07/25 12:37, Antony Lee <antony.lee@xxxxxxxxxxxx> 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)'.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author