list.without()?
Preston Landers
prestonlanders at my-deja.com
Wed Nov 17 13:07:24 EST 1999
In article <NDBBIAPHEKGOBIHCBLIIEEOOCAAA.mcfletch at vrtelecom.com>,
"Mike Fletcher" <mcfletch at vrtelecom.com> 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
factor,
> not really a contender.
> Third is the lambda solution (which does surprisingly well)
<without3> --
> gives acceptable but not great performance all over, seems strange
that
> 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,
marginally
> 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
(assuming
> few-in-many is the most common case, but that many-in-many is a
potential
> case). Third might be preferred due to the simplicity of the
implementation
> and similar speed. For maximum few-in-many speed, the fifth is the
most
> 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
--
|| Preston Landers <prestonlanders at my-deja.com> ||
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list