[Python-ideas] Allow isinstance second argument to be a set of types

Gregory P. Smith greg at krypto.org
Mon Jul 4 19:51:01 CEST 2011


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.


>
> 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/91d733fa/attachment.html>


More information about the Python-ideas mailing list