Peter Bengtsson <[EMAIL PROTECTED]> writes: > My poor understanding is that the difference between `sorted(somelist, > key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one > returns a new list and the other sorts in-place.
Yes. > Does that mean that .sort() is more efficient and should be favored > when you can (i.e. when you don't mind changing the listish object)? No, it means you should choose the version that expresses what you actually want to do. Efficiency of the programmers — including the unknown number of programmers who will have to read the code after you write it — is in many cases a much more important criterion than efficiency of the CPU. People's time continues to be much more expensive than computer time, after all. -- \ "Are you pondering what I'm pondering?" "Umm, I think so, | `\ Brain, but what if the chicken won't wear the nylons?" -- | _o__) _Pinky and The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list