Algorithm used by keyword 'in'
Michael Hudson
mwh at python.net
Mon Oct 11 11:46:50 EDT 2004
dataangel <k04jg02 at kzoo.edu> writes:
> Derek Rhodes wrote:
>
> >>In addition to John Roth's post, see the bottom of
> >>http://docs.python.org/ref/sequence-types.html , which will help you
> >>create your own algorithms for your own classes, if you like.
> >>
> >
> >Thanks for quick response guys.
> >
> > -Derek.
> Is python smart enough to do say a binary search if you sort the list
> right before using in?
No. How would Python be able to tell the list was sorted? There's
the bisect module for when *you* know the list is sorted.
Cheers,
mwh
--
The ability to quote is a serviceable substitute for wit.
-- W. Somerset Maugham
More information about the Python-list
mailing list