From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28857 invoked by alias); 25 Jul 2015 19:03:09 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35907 Received: (qmail 6724 invoked from network); 25 Jul 2015 19:03:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Biglobe-Sender: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: Improvement to python module list generation used for command completion From: "Jun T." In-Reply-To: Date: Sun, 26 Jul 2015 03:18:12 +0900 Content-Transfer-Encoding: 7bit Message-Id: References: To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1878.6) X-Biglobe-Spnum: 55072 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)'.