On Wednesday, October 15, 2003, at 12:35 PM, Barry Warsaw wrote: > While we're hacking on [].sort(), how horrible would it be if we > modified it to return self instead of None? I don't mind the > sort-in-place behavior, but it's just so inconvenient that it doesn't > return anything useful. I know it would be better if it returned a new > list, but practicality beats purity. <wink> When doing DSU sorting, the in-place sorting isn't really a performance win, is it? You already have to allocate and populate an entire alternate list with the sort keys, though I suppose you could have those mini key structs point to the original list. Anyway, while it's obviously in bad taste to propose .sort change its return value based on the presence of a key, wouldn't it be good if we had access to the new sorted list, instead of always clobbering the original list? Otherwise people's sorted() functions will end up copying lists unnecessarily. Okay, really I'm just hoping for [x for x in l sortby key(x)], if not now then someday -- if only there was a decent way of expressing that without a keyword... [...in l : key(x)] is the only thing I can think of that would be syntactically possible (without introducing a new keyword, new punctuation, or reusing a wholely inappropriate existing keyword). Or ";" instead of ":", but neither is very good. Sigh... -- Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4