News for hackers. Stuff that matters.
Re:Improving your (Python) code with modern idioms by sophacles on Tuesday May 08, 2012 @01:33AM (#3942399)
It depends on you case.

If you are doing:

   slist = list(mylist) #create new copy of the list
   slist.sort() #sort the list
   use_sorted_list(slist)
The use of sorted is more more convenient, and really doesn't use more memory (since the memory from that statement you quoted is for the list copy).

More usefully: sorted will take anything that is iterable, allowing you to write simpler code, rather than testing for various types and dealing with them in type specific ways.

There are no comments on this comment yet.