Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105688

Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python
Date Sat, 26 Mar 2016 00:22:33 +1100
Lines 29
Message-ID <mailman.3.1458912161.28225.python-list@python.org> (permalink)
References <a894d5ed-d906-4ff7-a537-32bf0187e062@googlegroups.com> <nb6aqh$dp5$1@ger.gmane.org> <DUB123-W22AD13A14B7564949220F683830@phx.gbl>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de aY8fsSyni5nkmReMbH/JRgowBsbX2m7eoRLEgjjMu/Xg==
Return-Path <rosuav@gmail.com>
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; 'else:': 0.03; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'one?': 0.05; 'false,': 0.07; 'cc:addr:python-list': 0.09; 'arg': 0.09; 'handling,': 0.09; 'none.': 0.09; 'python': 0.10; 'def': 0.13; 'subject: \n ': 0.15; 'things.': 0.15; '"is"': 0.16; "(it's": 0.16; '2016': 0.16; ':))': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'iterator,': 0.16; 'object()': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'byte': 0.18; "shouldn't": 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'sat,': 0.23; 'header:In- Reply-To:1': 0.24; 'checking': 0.27; 'message-id:@mail.gmail.com': 0.27; 'party,': 0.29; 'str': 0.29; 'objects': 0.29; 'checks': 0.30; 'anyone': 0.32; 'says': 0.32; 'common': 0.33; 'values.': 0.33; 'received:google.com': 0.35; 'text': 0.35; 'identity': 0.35; "isn't": 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'late': 0.38; 'received:209': 0.38; 'where': 0.40; 'some': 0.40; 'care': 0.60; 'more': 0.63; 'necessarily': 0.63; 'mar': 0.65; '26,': 0.72; 'chrisa': 0.84; 'to:none': 0.91; 'thing,': 0.93; 'story.': 0.96
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; bh=OwvdbcMWd2AUmr7Pq5xnT99oWx/jXnkVkYBR2aDvrQg=; b=mAhYnKjnbqOUTqTj78M2OxN6vqsr9Qd/nU4et2KNXaZwLXRh0BZynPK6y0U+G6RPAT H9r3R1kJYxd1HIHciIQvRsGi3vBH+ntKV/Vqe6m9HyMKGMXz0SU3mSAiaGqUsv3ERi+z 1MtoQq2hYZIvaaTkEdmtfdvZLDN/Nf8rVO2ybNqasgZwona0do0Jnq0nT8LeEPaoM0QJ GibE2Ga5UBgWd2Nw/8Lzsoo+8sqmhrxPfGMbXw3+HFlK/iU1FnzRlVSEZExneyv785BO 1Evquc0pLlCIwLiyndZ/6DZq6OFHbtLiVUc+gMmHeQmyqk8Kh9GjE6SIUMEqFmyQ9gut uOnw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=OwvdbcMWd2AUmr7Pq5xnT99oWx/jXnkVkYBR2aDvrQg=; b=fRdg/i4arT+mOLNcrKgsshpT2DADrcUgZLN2ZdVpZNtcOU1b1r4d1W6NhZ0qnrZh2x 4/gq6KFzhjzWgI+gIOa25VGu1dEaw2Yv7lSM4gUmtQx05Bs7/gcPYQCJzp+w0VYy5iNq oQPw8BlgrCzZni6t3uK4MNj6Q2b7fM0wmZizJLeauo1qJ73Saf842jMzXreC6en1Icti hv7mwG6jP3cwm7LHQegzuZmJEWA/WziBxR+Ch0gpGqOJ7rJwWYmVMgkRx0JIsrzcx0gH 32WVSDFu31J8WVAaHgt7L5xGpcmjJF/7MAOPDKdvfg7IMUgnslcldBRr1QMRTczubhPH +69g==
X-Gm-Message-State AD7BkJK6TKZTJFB1FEwtN0CxprYLUA0sn/xdTPFHXL8zdpN4o3wGacxDfcZiOIH4hZpZP+wzytlmp59wBQqMPw==
X-Received by 10.107.169.105 with SMTP id s102mr12909506ioe.19.1458912153459; Fri, 25 Mar 2016 06:22:33 -0700 (PDT)
In-Reply-To <DUB123-W22AD13A14B7564949220F683830@phx.gbl>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:105688

Show key headers only | View raw


On Sat, Mar 26, 2016 at 12:03 AM, Albert-Jan Roskam
<sjeik_appie@hotmail.com> wrote:
>> You should not bother with object identity for objects other than None.
>
>
> A little late to the party, but: how about Ellipsis? Shouldn't "is" also be used for that one? (It's rare, I know :))

Yes, and also True and False, if you're checking for the specific
values. (Though it's more common in Python to merely care about
truthiness/falsiness.) Other common identity checks include:

if str is bytes:
    # Python 2 handling, where "native strings" are byte strings
else:
    # Python 3 handling, where "native strings" are text strings

if iter(x) is x:
    # x is an iterator, not some other iterable

_SENTINEL = object()
def func(arg=_SENTINEL):
    if arg is _SENTINEL:
        # arg was not passed

Anyone who says that identity checks are only for None is
significantly over-simplifying things. This isn't necessarily a bad
thing, but it should never be taken to be the whole story.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Explaining  names  vs variables  in Python Salvatore DI DIO <salvatore.didio@gmail.com> - 2016-03-02 00:32 -0800
  Re: Explaining names vs variables in Python Jesper K Brogaard <jesper@brogAAaard.eu> - 2016-03-02 10:03 +0100
    Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-02 21:32 +1100
      Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 14:34 +0200
        Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-02 23:50 +1100
          Re: Explaining names vs variables in Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-02 15:11 +0200
          Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 15:39 +0200
            Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-03 00:48 +1100
              Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 16:11 +0200
                Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-02 07:08 -0800
                Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 04:23 +1100
                Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-02 09:28 -0800
                Re: Explaining names vs variables in Python Marko Rauhamaa <marko@pacujo.net> - 2016-03-02 20:12 +0200
                Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 12:52 +1100
                Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-03 09:03 -0800
                Re: Explaining names vs variables in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-03 12:53 -0700
                Re: Explaining names vs variables in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-02 21:49 +0000
                Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 13:05 +1100
                Re: Explaining names vs variables in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-03 16:09 +0000
                Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-03 08:52 +1100
                Re: Explaining names vs variables in Python Rustom Mody <rustompmody@gmail.com> - 2016-03-02 17:23 -0800
                Re: Explaining names vs variables in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-02 22:51 +0000
              Re: Explaining names vs variables in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-03 04:10 +1100
  Re: Explaining names vs variables in Python Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-03-02 10:08 +0100
  Effects of caching frequently used objects, was Re: Explaining  names  vs variables  in Python Peter Otten <__peter__@web.de> - 2016-03-02 10:12 +0100
  Re: Explaining  names  vs variables  in Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-02 11:35 +0200
    Re: Explaining names vs variables in Python Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-02 08:13 -0700
      Re: Explaining names vs variables in Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-02 17:37 +0200
  Re: Explaining  names  vs variables  in Python Steven D'Aprano <steve@pearwood.info> - 2016-03-02 21:16 +1100
  Re: Explaining  names  vs variables  in Python "ast" <nomail@invalid.com> - 2016-03-02 11:52 +0100
    Re: Explaining  names  vs variables  in Python Salvatore DI DIO <salvatore.didio@gmail.com> - 2016-03-02 02:58 -0800
  Re: Effects of caching frequently used objects, was Re: Explaining  names  vs variables  in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-02 09:16 -0500
  Re: Explaining  names  vs variables  in Python Ben Finney <ben+python@benfinney.id.au> - 2016-03-03 04:53 +1100
  RE: Effects of caching frequently used objects, was Re: Explaining names  vs variables  in Python Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2016-03-25 13:03 +0000
  Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python Chris Angelico <rosuav@gmail.com> - 2016-03-26 00:22 +1100
  Re: Effects of caching frequently used objects, was Re: Explaining names  vs variables  in Python Ethan Furman <ethan@stoneleaf.us> - 2016-03-25 09:45 -0700

csiph-web