[Python-ideas] Allow isinstance second argument to be a set of types
Gregory P. Smith
greg at krypto.org
Mon Jul 4 19:52:37 CEST 2011
On Mon, Jul 4, 2011 at 10:51 AM, Gregory P. Smith <greg at krypto.org> wrote:
>
>
> On Mon, Jul 4, 2011 at 8:28 AM, Antoine Pitrou <solipsis at pitrou.net>wrote:
>
>> On Mon, 4 Jul 2011 15:35:55 +0100
>> Michael Foord <fuzzyman at gmail.com> wrote:
>> > On 4 July 2011 08:02, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> >
>> > > Michael Foord wrote:
>> > >
>> > > It would feel cleaner to me if I could make FunctionTypes a set and
>> use
>> > >> that as the second argument to isinstance. :-)
>> > >>
>> > >
>> > > Or more generally, any iterable object?
>> >
>> > I don't care about any iterable. If a set would work then I'd be happy.
>> :-)
>>
>> Sure, but making it work for tuples and sets, but not other iterables,
>> would be a pretty lousy API.
>>
>
> A set lookup should be faster than iteration for anything over ~3 types. I
> support the change even if it doesn't include all iterables. The use case
> for arbitrary iterables of types to isinstance seems low.
>
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.
>
>
>>
>> Regards
>>
>> Antoine.
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110704/600af0cf/attachment.html>
More information about the Python-ideas
mailing list