GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing mail.python.org — [Python-Dev] decorate-sort-undecorate [Python-Dev] decorate-sort-undecorateRaymond Hettinger python at rcn.comThu Oct 16 10:26:50 EDT 2003
[Alex Martelli] > I thought the idea being implemented avoided making a new list -- > i.e., that the idea being implemented is the equivalent of: > > # decorate > for i, item in enumerate(thelist): > thelist[i] = CleverWrapper((key(item), item)) > > # sort (with the new stability guarantee) > thelist.sort() > > # undecorate > for i, item in enumerate(thelist): > thelist[i] = item[1] > > where (the equivalent of): > > class CleverWrapper(tuple): > def __cmp__(self, other): return cmp(self[0], other[0]) > > so, there is no allocation of another list -- just (twice) a repopulation > of the existing one. How _important_ that is to performance, I dunno, > but wanted to double-check on my understanding of this anyway. Yes, that is how it works in a nutshell ;-) Of course, it looks more impressive and was harder to write in C. Raymond Hettinger
More information about the Python-Dev mailing list |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |