Algorithm help per favore

Curly Joe woooee at yahoo.com
Thu Jun 19 00:28:35 CEST 2003


Correct me if I'm wrong, but doesn't the compiler
break all of these solutions down into approximately
the same thing? The compiler has to physically step
through the list one by one no matter how you phrase
the code, so there would be no gain in speed.  There
might be a small speedup for larger lists if you
placed the previous element in a variable and compare
the variable to this element, because then the
compiler would only have to access one element instead
of two elements in each pass.  But aside from that it
seems that it is all window dressing IMHO.  I'm no
expert on lists.  Good question though.


> --- In python-list at yahoogroups.com, wrbt at e...
> (Larry) wrote:
> > I need to take a list (probably 20k to 40k
> elements) of numbers and
> > remove consecutive duplicates. Non consecutive
> duplicates are ok.
> > 
> > Example: [6,3,3,3,5,7,6,3,4,4,3] =>
> [6,3,5,7,6,3,4,3]
> > 
> > The 3 and 6 can appear more than once in the
> result set because
> > they're separated by another value. Obviously this
> is trivial to
> > accomplish by walking thru the list and building a
> new one (or yanking
> > elements out of the existing one) but I'm curious
> if anyone knows of a
> > more clever way, with speed being a goal more than
> memory usage.
> > -- 
> >
> http://mail.python.org/mailman/listinfo/python-list
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com





More information about the Python-list mailing list