Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'subject:Python': 0.06; 'exception.': 0.09; 'from:addr:python': 0.09; 'subclass': 0.09; 'tuple': 0.09; 'type)': 0.09; 'subject:] ': 0.14; 'wrote:': 0.15; 'antoine': 0.16; 'arbitrarily': 0.16; 'element,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'lookup': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr :python-list': 0.16; 'subject: \n ': 0.16; 'subject:set': 0.16; '\xe9crit': 0.16; '>>>': 0.16; 'header:In-Reply-To:1': 0.22; 'gregory': 0.23; 'suspect': 0.25; '(or': 0.25; 'raise': 0.28; 'objects': 0.28; 'received:84': 0.28; 'iterating': 0.30; 'types.': 0.30; 'hi,': 0.31; 'rather': 0.33; 'actually': 0.33; 'to:addr :python-list': 0.34; 'header:User-Agent:1': 0.34; 'difference': 0.34; 'implies': 0.35; 'reply-to:addr:python.org': 0.35; 'probably': 0.35; 'anything': 0.37; 'else': 0.38; 'case,': 0.38; 'case': 0.39; 'should': 0.39; 'to:addr:python.org': 0.39; 'back': 0.63; 'making': 0.66; 'exact': 0.69; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; '10:52': 0.84; 'beware': 0.84; 'subject:types': 0.84; 'fast,': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmcHAAgZEk5UXebj/2dsb2JhbABTmQmOc3eIfMEhhjYEly6LPw Date: Mon, 04 Jul 2011 20:53:47 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: [Python-ideas] Allow isinstance second argument to be a set of types References: <4E11656B.4050908@canterbury.ac.nz> <20110704172843.50c5b445@pitrou.net> <1309802125.3688.54.camel@localhost.localdomain> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1309809227 news.xs4all.nl 21867 [2001:888:2000:d::a6]:42558 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8790 On 04/07/2011 20:41, Amaury Forgeot d'Arc wrote: > Hi, > > 2011/7/4 Antoine Pitrou: >> Le lundi 04 juillet 2011 à 10:52 -0700, Gregory P. Smith a écrit : >>> note that a fast lookup implies exact type and not subclass making my >>> point silly... at which point you're back to iterating so I suspect >>> supporting arbitrary iterables is actually how this will be >>> implemented regardless. >> >> Indeed. Note that the tuple case should remain fast, and therefore >> special-cased (or the general list/tuple case, since the difference in C >> is rather small). > > Arbitrary iterables, arbitrarily nested... > beware of objects which are also their first element, like str('a')... > Probably not arbitrarily nested, just a type (type(t) is type) or an iterable yielding types. Anything else would raise an exception.