> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
--
Robert L. Miller
http://www.rlmiller.org/
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