From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16222 invoked by alias); 25 Jul 2015 03:37:51 -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: 35899 Received: (qmail 11965 invoked from network); 25 Jul 2015 03:37:49 -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=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=mpM8mrPun5jlf3U1b9mpxriJEaZMt0KiJc4jxFvfil4=; b=QDeU9ikOnXQvE7JCctIJ5Mdg6zb79C5takM6nTy5hw0bDAO8jccGIK5Lf8YXKP2ixb j769O1UHv9T6fzUl4UbHw2kVXkxL5z4tLbhDiHympvnAUBUH+PQVMhPb9FxyXzu2i0sg tRYgMcxATCYWqYasvmYaqdkUFnVre71dbpaymRr+U+5KE2z5U8I9HkErqyCfI59JQM8m IEwGoRQIaCSdpFFvL+wZ5TtQ5JKUMjv9dm31Eb1JCPbTf/MQZ/OmrkVw8112QtATuvjU Bwn4/8nvujdOAgahsJrwQigdtTWtv6TXRn0S0T+G13nlmKeeJYveXHulU/zgAFuJOwkm 0sMA== X-Received: by 10.202.52.138 with SMTP id b132mr17237547oia.125.1437795467734; Fri, 24 Jul 2015 20:37:47 -0700 (PDT) MIME-Version: 1.0 Sender: anntzer.lee@gmail.com From: Antony Lee Date: Fri, 24 Jul 2015 20:37:28 -0700 X-Google-Sender-Auth: LiICGpDMnf6g7HL1dK-L2mUeHe0 Message-ID: Subject: Improvement to python module list generation used for command completion To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary=001a113d3e021d3579051baad811 --001a113d3e021d3579051baad811 Content-Type: text/plain; charset=UTF-8 Currently, both the completion for python -m and for pydoc require a list of available python modules, generated in _python_modules. This uses pydoc's ModuleScanner, which is unbearably slow on systems with just a few big packages installed because it also searches for submodules, and thus has to import all packages(!) available on the path. Instead, pkgutil.iter_modules (available at least since python 2.6) only returns toplevel modules, 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. Best, Antony --001a113d3e021d3579051baad811--