all pairs of items in a list without indexing?
aleaxit at yahoo.com
Wed Sep 29 19:16:36 CEST 2004
Steven Bethard <steven.bethard at gmail.com> wrote:
> > > but that seems like a lot of wasteful list slicing...
> > Sorry, I don't get it: what's wasteful about it?
> Sorry, perhaps I should have said it has a bad smell. I wasn't the only one
> who thought this smelled a little bad; quoting Jeff:
> "Something about taking a slice of seq for the inner loop doesn't seem right
> to me."
> Maybe we need to retrain our noses. ;)
Hmmm, I see (or should I say, I sniff). Perhaps a Numeric.array, where
slices share slots rather than making new slots, would smell better and
might indeed perform faster here. But the comparison is with index
loops on xrange(i,len(l)), which is hardly Chanel N. 5 either...;-).
More information about the Python-list