Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; '*is*': 0.09; 'false,': 0.09; 'objects,': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'mostly': 0.14; '415': 0.16; 'alexander': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'grep': 0.16; 'none.': 0.16; 'operators.': 0.16; 'sentinel': 0.16; 'singular': 0.16; 'url:py': 0.16; 'uses,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'not,': 0.20; 'code,': 0.22; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'tells': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'object.': 0.31; 'project:': 0.31; 'class': 0.32; 'probably': 0.32; 'run': 0.32; 'not.': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'doing': 0.36; "didn't": 0.36; 'two': 0.37; 'pm,': 0.38; 'recent': 0.39; 'such': 0.63; 'different': 0.65; 'mar': 0.68; 'production': 0.68; 'truth': 0.81; '620': 0.84; 'url:master': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=pGjX/GLrugCjeuwkzYI+vVHVzx6RytbWAjFPvhIJLPU=; b=Dwt9mLtGnmuytnIX7qc36w3+vHowvchQattnuzs7CjkUAqmd/jCQ4SL0segmAgbd2V l34Mq6TKzOmW7gL2mfhBog6cYLyJYsS9KfLVh4g5MaAO9T4G0jI5uTDXEGHLLL+JvCev 8eJaSnNKXpj+cIWxRSJyde3KzcCZ6h0vZ2XfVCRqwa/+1baQCsWjGe9vRraSmkXnqTgb gSaiH+MVw71n/L2U4cG9FvF0TQ+LfSh6M5EDTo04WX8MKl7SQt2J5l74zNR/BBZT8hFY +iqtS3JtV+jSUPlye5UO1zH1RE1uKk8D1tSHM2tkbt9c92bNpx2VPhbEN13q28Ol2yBQ 2jwQ== MIME-Version: 1.0 X-Received: by 10.66.129.133 with SMTP id nw5mr6284893pab.98.1393941980439; Tue, 04 Mar 2014 06:06:20 -0800 (PST) In-Reply-To: <5315cd4b$0$6670$9b4e6d93@newsspool2.arcor-online.net> References: <53144e8d$0$2149$426a74cc@news.free.fr> <5315cd4b$0$6670$9b4e6d93@newsspool2.arcor-online.net> Date: Wed, 5 Mar 2014 01:06:20 +1100 Subject: Re: Reference From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1393941984 news.xs4all.nl 2842 [2001:888:2000:d::a6]:37774 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67677 On Tue, Mar 4, 2014 at 11:55 PM, Alexander Blinne wrote: > Am 03.03.2014 19:48, schrieb Terry Reedy: >> The 'is' operator has three uses, two intended and one not. In >> production code, 'is' tests that an object *is* a particular singular >> object, such as None or a sentinel instance of class object. > > Just a bit of statistics on this one from a recent small project: > > <13:51:20> alex@firefly$ grep ' is ' *.py | wc > 65 415 3234 > <13:51:35> alex@firefly$ grep ' is None' *.py | wc > 43 243 1948 > <13:51:40> alex@firefly$ grep ' is not None' *.py | wc > 21 167 1241 > <13:51:44> alex@firefly$ grep ' is False' *.py | wc > 1 5 45 > > No other uses if 'is' found in almost 3 KLOC... Lemme spin you up a different way of doing it, which actually looks for the operators. https://github.com/Rosuav/ExceptExpr/blob/master/find_except_expr.py Run across the Python stdlib, that tells me there are 4040 uses of is/is not, of which 16 compare against False, 18 against True (see? Python has a bias for truth above falsehood!), and 3386 against None. The other 620 are probably mostly sentinel objects, but I didn't look at them. ChrisA