copysort patch, was RE: [Python-Dev] inline sort option
Mark Russell
marktrussell at btopenworld.com
Tue Oct 21 07:18:16 EDT 2003
On Tue, 2003-10-21 at 12:00, Alex Martelli wrote:
> Why should multiple data types acquire separate .sort methods with
> subtly different semantics (one works in-place and returns None, one
> doesn't mutate the object and returns a list, ...) when there's no real
> added value wrt ONE classmethod of list...?
I agree that the different semantics for lists and dicts are a strike
against this. The argument for it is that walking over a dictionary in
sorted order is (at least to me) a missing idiom in python. Does this
never come up when you're teaching the language?
I wouldn't advocate adding this to other types (e.g. Set) because
they're much less commonly used than dicts, so I don't think there's a
danger of a creeping plague of sort methods. Not a big deal though -
list.sorted() is the real win.
Mark Russell
PS: I'm really not an anal-retentive keystoke counter :-)
More information about the Python-Dev
mailing list