[Tutor] Binary search question

Alan Gauld alan.gauld at btinternet.com
Sat Apr 24 01:31:58 CEST 2010

"Robert Berman" <bermanrl at cfl.rr.com> wrote

> But, even though my years of experience using Python is less than 4 I would be
> reluctant to use 'in' just based on what I have been reading from those who
> took the time to answer my post. Just my $0.02 worth.

It depends, if you are transmitting the data across a slow network then it might
take 10 minutes to do that. So who cares if the in search takes 10 seconds?
And its by far the easiest and most readable solution. OTOH if your whole
program takes 1 second apart from the search then you probably do want to
optimise things.

As always use the simplest solution and only if it really needs to go faster
then optimise it.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list