From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12413 invoked by alias); 25 Jul 2015 21:34:12 -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: 35911 Received: (qmail 18900 invoked from network); 25 Jul 2015 21:34:08 -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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=oyd4wcoce6mdfSId8TNOSnowSa4cRcIQmNeJ8D8RCjA=; b=DsbUIB+YN2J1cNZpQIAR7iVzWjp6kcSBWaRY3u/SzNIP3fIJJML6NKr3BzAr+pJ4bB +CifN0TdmXUo+H44m8ErkY04AfMdh2fZ7UemFGwfXXo8BQgQcresq9BYLSvzprQ5E+AA q52GqIkYTZoIGZwy6g2wd5zLrAOHIZ0EkbS4mspXtHcwvgNK0visSIXdDY/G7pmceRP3 hkMcs6Or29gTgV1zeCOdnRna/TNsFoqlgMr0v0uPV2Tikz8toPvCtmimmz3jzw+68nF2 9w+THNk/tZlLLWPC8MTl6c+GTLSVBEEW024koB4WIokMAMFPHfS4jzJ3fdpO0CriOI4W JBag== X-Received: by 10.182.236.200 with SMTP id uw8mr20889640obc.19.1437860045461; Sat, 25 Jul 2015 14:34:05 -0700 (PDT) MIME-Version: 1.0 Sender: anntzer.lee@gmail.com In-Reply-To: References: From: Antony Lee Date: Sat, 25 Jul 2015 14:33:46 -0700 X-Google-Sender-Auth: 482qdi8FxIf2kZZOMb8RPTmci10 Message-ID: Subject: Re: Improvement to python module list generation used for command completion To: "Jun T." Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary=001a11c362163f1f26051bb9e106 --001a11c362163f1f26051bb9e106 Content-Type: text/plain; charset=UTF-8 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)'. > --001a11c362163f1f26051bb9e106--