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:
> First is the posted algo (while,try,except,break) <without>
> good performance for the few-in-many case but very poor performance
> many in many cases for large values of many
> Second is a for loop with == test and append <without2> --
> (but not spectacular) results whenever memory effects are not a big
> not really a contender.
> Third is the lambda solution (which does surprisingly well)
> 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
> few-in-many case, again, very poor results in many-in-many case
> 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
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 my-deja.com> ||
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list