[pypy-svn] rev 2517 - pypy/trunk/src/pypy/objspace/std
pmaupin at codespeak.net
pmaupin at codespeak.net
Thu Dec 18 16:40:15 CET 2003
Author: pmaupin
Date: Thu Dec 18 16:40:15 2003
New Revision: 2517
Modified:
pypy/trunk/src/pypy/objspace/std/listobject.py
pypy/trunk/src/pypy/objspace/std/listtype.py
Log:
Added sort(list,cmp) functionality
Modified: pypy/trunk/src/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/listobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/listobject.py Thu Dec 18 16:40:15 2003
@@ -491,9 +491,13 @@
_quicksort(list, start, split-1, lt) # ... and sort both halves.
_quicksort(list, split+1, end, lt)
-def list_sort__List(space, w_list):
- def lt(a,b):
- return space.is_true(space.lt(a,b))
+def list_sort__List_ANY(space, w_list, w_cmp):
+ if w_cmp is space.w_None:
+ def lt(a,b):
+ return space.is_true(space.lt(a,b))
+ else:
+ def lt(a,b):
+ return space.unwrap(space.call_function(w_cmp, a, b)) < 0
# XXX Basic quicksort implementation
# XXX this is not stable !!
Modified: pypy/trunk/src/pypy/objspace/std/listtype.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/listtype.py (original)
+++ pypy/trunk/src/pypy/objspace/std/listtype.py Thu Dec 18 16:40:15 2003
@@ -14,7 +14,7 @@
list_index = MultiMethod('index', 4, defaults=(0,maxint))
list_count = MultiMethod('count', 2)
list_reverse= MultiMethod('reverse',1)
- list_sort = MultiMethod('sort', 1)
+ list_sort = MultiMethod('sort', 2, defaults=(None,))
registerimplementation(W_ListType)
More information about the Pypy-commit
mailing list