Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '+++': 0.03; '(at': 0.04; 'importing': 0.05; 'that?': 0.05; 'sys': 0.07; '+1,5': 0.09; '+import': 0.09; '-0500': 0.09; 'collier': 0.09; 'latter': 0.09; 'recommends': 0.09; 'sys,': 0.09; 'cc:addr:python-list': 0.11; '-1,4': 0.16; '-import': 0.16; '-tkc': 0.16; 'added.': 0.16; 'cleaner': 0.16; 'csv': 0.16; 'csv,': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'imports': 0.16; 'pep8': 0.16; 'subject:import': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; '---': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'this:': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'especially': 0.30; 'easier': 0.31; 'usually': 0.31; 'os,': 0.31; 'figure': 0.32; 'johnson': 0.35; 'but': 0.35; 'there': 0.35; 'done': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'so,': 0.37; 'performance': 0.37; 'rather': 0.38; 'read': 0.60; 'more': 0.64; 'spot': 0.65; 'to:addr:gmail.com': 0.65; 'believe': 0.68; 'received:50.22': 0.84; 'tolerant': 0.84; 'on?': 0.91 Date: Mon, 29 Jul 2013 15:14:45 -0500 From: Tim Chase To: Devyn Collier Johnson Subject: Re: import syntax In-Reply-To: <51F6C720.2020404@Gmail.com> References: <51F6C720.2020404@Gmail.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: none Cc: Python Mailing List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375128799 news.xs4all.nl 15882 [2001:888:2000:d::a6]:46797 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51486 On 2013-07-29 15:48, Devyn Collier Johnson wrote: > The PEP8 recommends importing like this: > > import os > import re > > not like this: > > import os, re > > Why is that? Is there a performance advantage to one of the styles? While I don't believe there's much of a performance difference (if so, it should be pretty negligible, especially since imports are usually just done at load-time rather than run-time), but 1) it's easier to read one-per-line (IMHO), particularly if you sort them alphabetically 2) it makes for cleaner diffs Which would you rather read and try to figure out what's going on? ===================================== --- before.py 2013-07-29 15:04:38.250996094 -0500 +++ after.py 2013-07-29 15:04:44.026996132 -0500 @@ -1 +1 @@ -import csv, re, sys, os +import csv, re, sys, glob, os ===================================== vs. ===================================== --- before.py 2013-07-29 15:13:13.050997907 -0500 +++ after.py 2013-07-29 15:13:18.434997950 -0500 @@ -1,4 +1,5 @@ import csv +import glob import os import re import sys ===================================== The latter makes it much easier (at least for me) to spot that "glob" was added. And it's more tolerant of merge-conflict resolution. -tkc