Algorithm help per favore

Larry wrbt at email.com
Thu Jun 19 14:49:42 EDT 2003


bokr at oz.net (Bengt Richter) wrote in message news:<bcqs53$hrb$0 at 216.39.172.122>...
> On Wed, 18 Jun 2003 15:28:35 -0700 (PDT), Curly Joe <woooee at yahoo.com> wrote:
> 
> >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.
> >
> There's a lot of difference in what happens. E.g., if you zip
> an offset copy to make a list of tuples, you've duplicated the
> first list and made an equally long list of 2-tuples. And then
> you start constructing the result list.
> 
> Destructive modification of the original list is going to take
> very much less space for large lists, and likely be faster (depending
> on how you do it ;-)
> 
> You can compare the code generated by disassembling with the dis module.
> 
> Regards,
> Bengt Richter

Sheesh this group (and the Python community) rule. Thanks for all the
help and suggestions, and everyone please have a great weekend.

- Larry




More information about the Python-list mailing list