Hi Carl, Thanks for the heads-up, its been so long since I read the Python 3 changes and that one hadn't stuck. Will do.
Rob On Jul 24, 1:20 pm, Carl Witty <carl.wi...@gmail.com> wrote: > On Sat, Jul 24, 2010 at 11:54 AM, Rob Beezer <goo...@beezer.cotse.net> wrote: > > So it is a verb. ;-) > > > Looks like similar comments apply to edges(). > > > I'm thinking that optionally passing in a comparison function would be > > a nice thing to add - a minor convenience, but also it would drive > > home the point that the sorting is somewhat the caller's > > responsibility in non-trivial situations (ie for not most users). > > > I'll get a ticket started soon. > > Note that Python 3 has removed the comparison function argument for > List.sort() and similar functions, in favor of a "key" argument giving > a function that transforms a list element into a sortable element. > For example, if you want to sort by string representations, currently > you could do: > > verts.sort(cmp=lambda a, b: cmp(str(a), str(b))) > > but in Python 3 you would have to do: > > verts.sort(key=str) > > The idea is to discourage inefficient programming; the Python 3 > version is better, because it calls str() on each element only once, > whereas the old version calls str() on each element O(log(N)) times. > > Our current Python also has a key= argument for sort(). > > I suggest that we should follow Python 3 here for such APIs, and > optionally pass in a key= function rather than a cmp= comparison > function. > > Carl -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org