[pypy-svn] r8618 - pypy/dist/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Wed Jan 26 17:59:10 CET 2005


Author: arigo
Date: Wed Jan 26 17:59:10 2005
New Revision: 8618

Modified:
   pypy/dist/pypy/objspace/std/listtype.py
   pypy/dist/pypy/objspace/std/stdtypedef.py
Log:
Allow arguments to be named in the stdobjspace's type's methods.
As a first example, this enables  list.sort(cmp=...) .



Modified: pypy/dist/pypy/objspace/std/listtype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/listtype.py	(original)
+++ pypy/dist/pypy/objspace/std/listtype.py	Wed Jan 26 17:59:10 2005
@@ -10,7 +10,7 @@
 list_index    = MultiMethod('index',  4, defaults=(0,maxint))
 list_count    = MultiMethod('count',  2)
 list_reverse  = MultiMethod('reverse',1)
-list_sort     = MultiMethod('sort',   2, defaults=(None,))
+list_sort     = MultiMethod('sort',   2, defaults=(None,), argnames=['cmp'])
 list_reversed = MultiMethod('__reversed__', 1)
 
 def app_list_reversed__ANY(lst):

Modified: pypy/dist/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stdtypedef.py	(original)
+++ pypy/dist/pypy/objspace/std/stdtypedef.py	Wed Jan 26 17:59:10 2005
@@ -187,7 +187,9 @@
         self.typeclass = typeclass
         self.bound_position = bound_position
         self.framecls = framecls
-        argnames = ['x%d'%(i+1) for i in range(multimethod.arity)]
+        argnames = ['_%d'%(i+1) for i in range(multimethod.arity)]
+        explicit_argnames = multimethod.extras.get('argnames', [])
+        argnames[len(argnames)-len(explicit_argnames):] = explicit_argnames
         varargname = kwargname = None
         # XXX do something about __call__ and __init__ which still use
         # XXX packed arguments: w_args, w_kwds instead of *args_w, **kwds_w



More information about the Pypy-commit mailing list