Preston Landers prestonlanders at
Wed Nov 17 13:07:24 EST 1999

  "Mike Fletcher" <mcfletch at> wrote:

> Conclusions:
> 	First is the posted algo (while,try,except,break) <without>
gives very
> good performance for the few-in-many case but very poor performance
for the
> many in many cases for large values of many
> 	Second is a for loop with == test and append <without2> --
gives decent
> (but not spectacular) results whenever memory effects are not a big
> not really a contender.
> 	Third is the lambda solution (which does surprisingly well)
<without3> --
> gives acceptable but not great performance all over, seems strange
> function-call-overhead is so minor a factor.
> 	Fourth is a backwards-index-counting scheme with del
<without4> -- gives
> marginally better performance than third on few-in-many case,
> worse than third in many-in-many case.
> 	Fifth is Preston's remove function <remove> -- gives best
results for
> few-in-many case, again, very poor results in many-in-many case
> Summary:
> 	Looks like the fourth algo is likely the "winner" in this set
> few-in-many is the most common case, but that many-in-many is a
> case).  Third might be preferred due to the simplicity of the
> and similar speed.  For maximum few-in-many speed, the fifth is the
> appropriate.

Excellent work, Mike.  Stuff like this is certainly good to know when
working a lot with lists! It looks like one conclusion we can draw from
this is that matching an algorithm to a data set is not always a
straightforward task.  It requires careful thought, familiarity with
the expected cases (few-in-many, many-in-many, etc) and most
importantly, experimentation.  Thanks again!


|| Preston Landers <prestonlanders at> ||

Sent via
Before you buy.

More information about the Python-list mailing list