[pypy-svn] r8958 - pypy/branch/dist-simpler-multimethods/pypy/objspace/std

pedronis at codespeak.net pedronis at codespeak.net
Mon Feb 7 17:47:06 CET 2005


Author: pedronis
Date: Mon Feb  7 17:47:06 2005
New Revision: 8958

Modified:
   pypy/branch/dist-simpler-multimethods/pypy/objspace/std/listobject.py
   pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stringobject.py
   pypy/branch/dist-simpler-multimethods/pypy/objspace/std/tupleobject.py
Log:
let again seqs mul and seqs getitem etc work with longs too



Modified: pypy/branch/dist-simpler-multimethods/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/objspace/std/listobject.py	(original)
+++ pypy/branch/dist-simpler-multimethods/pypy/objspace/std/listobject.py	Mon Feb  7 17:47:06 2005
@@ -57,9 +57,9 @@
     result = w_list.ob_size
     return W_IntObject(space, result)
 
-def getitem__List_Int(space, w_list, w_index):
+def getitem__List_ANY(space, w_list, w_index):
     items = w_list.ob_item
-    idx = w_index.intval
+    idx = space.int_w(w_index)
     if idx < 0:
         idx += w_list.ob_size
     if idx < 0 or idx >= w_list.ob_size:
@@ -114,9 +114,8 @@
     list_extend__List_ANY(space, w_list1, w_iterable2)
     return w_list1
 
-def mul__List_Int(space, w_list, w_int):
+def mul_list_times(space, w_list, times):
     w_res = W_ListObject(space, [])
-    times = w_int.intval
     src = w_list.ob_item
     size = w_list.ob_size
     newlen = size * times  # XXX check overflow
@@ -130,8 +129,11 @@
     w_res.ob_size = p
     return w_res
 
-def mul__Int_List(space, w_int, w_list):
-    return mul__List_Int(space, w_list, w_int)
+def mul__List_ANY(space, w_list, w_times):
+    return mul_list_times(space, w_list, space.int_w(w_times))
+
+def mul__ANY_List(space, w_times, w_list):
+    return mul_list_times(space, w_list, space.int_w(w_times))
 
 def eq__List_List(space, w_list1, w_list2):
     items1 = w_list1.ob_item
@@ -173,8 +175,8 @@
 # upto here, lists are nearly identical to tuples, despite the
 # fact that we now support over-allocation!
 
-def delitem__List_Int(space, w_list, w_idx):
-    i = w_idx.intval
+def delitem__List_ANY(space, w_list, w_idx):
+    i = space.int_w(w_idx)
     if i < 0:
         i += w_list.ob_size
     if i < 0 or i >= w_list.ob_size:
@@ -202,9 +204,9 @@
         _del_slice(w_list, i, i+1)
     return space.w_None
 
-def setitem__List_Int_ANY(space, w_list, w_index, w_any):
+def setitem__List_ANY_ANY(space, w_list, w_index, w_any):
     items = w_list.ob_item
-    idx = w_index.intval
+    idx = space.int_w(w_index)
     if idx < 0:
         idx += w_list.ob_size
     if idx < 0 or idx >= w_list.ob_size:

Modified: pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stringobject.py	(original)
+++ pypy/branch/dist-simpler-multimethods/pypy/objspace/std/stringobject.py	Mon Feb  7 17:47:06 2005
@@ -22,7 +22,7 @@
 __eq__            def eq__String_String(space, w_str1, w_str2):
 __ge__            def ge__String_String(space, w_str1, w_str2):
 __getattribute__
-__getitem__       def getitem__String_Int(space, w_str, w_int): def getitem__String_Slice(space, w_str, w_slice):
+__getitem__       def getitem__String_ANY(space, w_str, w_int): def getitem__String_Slice(space, w_str, w_slice):
 __getslice__
 __gt__            def gt__String_String(space, w_str1, w_str2):
 __hash__          def hash__String(space, w_str):
@@ -39,12 +39,12 @@
 __setattr__
 __str__           def str__String(space, w_str):
 capitalize        def str_capitalize__String(space, w_self):
-center            def str_center__String_Int(space, w_self):
-count             def str_count__String_String_Int_Int(space, w_self): [optional arguments not supported now]
+center            def str_center__String_ANY(space, w_self):
+count             def str_count__String_String_ANY_ANY(space, w_self): [optional arguments not supported now]
 decode            !Unicode not supported now
 encode            !Unicode not supported now
 endswith          str_endswith__String_String    [optional arguments not supported now]
-expandtabs        str_expandtabs__String_Int
+expandtabs        str_expandtabs__String_ANY
 find              OK
 index             OK
 isalnum           def str_isalnum__String(space, w_self): def _isalnum(ch):
@@ -63,7 +63,7 @@
 rindex            OK
 rjust             def str_rjust__String_ANY(space, w_self, w_arg):
 rstrip            def str_rstrip__String_String(space, w_self, w_chars):
-split             def str_split__String_None_Int(space, w_self, w_none, w_maxsplit=-1):def str_split__String_String_Int(space, w_self, w_by, w_maxsplit=-1):
+split             def str_split__String_None_ANY(space, w_self, w_none, w_maxsplit=-1):def str_split__String_String_ANY(space, w_self, w_by, w_maxsplit=-1):
 splitlines        def str_splitlines__String_String(space, w_self, w_keepends):
 startswith        str_startswith__String_String    [optional arguments not supported now]
 strip             def str_strip__String_String(space, w_self, w_chars):
@@ -890,8 +890,8 @@
     else:
         return space.w_False
 
-def getitem__String_Int(space, w_str, w_int):
-    ival = space.int_w(w_int)
+def getitem__String_ANY(space, w_str, w_index):
+    ival = space.int_w(w_index)
     str = w_str._value
     slen = len(str)
     if ival < 0:
@@ -912,9 +912,8 @@
     w_empty = space.newstring([])
     return str_join__String_ANY(space, w_empty, w_r)
 
-def mul__String_Int(space, w_str, w_mul):
+def mul_string_times(space, w_str, mul):
     input = w_str._value
-    mul = space.int_w(w_mul)
     if mul < 0:
         return space.wrap("")
     input_len = len(input)
@@ -931,8 +930,11 @@
 
     return space.wrap("".join(buffer))
 
-def mul__Int_String(space, w_mul, w_str):
-    return mul__String_Int(space, w_str, w_mul)
+def mul__String_ANY(space, w_str, w_times):
+    return mul_string_times(space, w_str, space.int_w(w_times))
+
+def mul__ANY_String(space, w_mul, w_str):
+    return mul_string_times(space, w_str, space.int_w(w_times))
 
 def add__String_String(space, w_left, w_right):
     right = w_right._value

Modified: pypy/branch/dist-simpler-multimethods/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/branch/dist-simpler-multimethods/pypy/objspace/std/tupleobject.py	(original)
+++ pypy/branch/dist-simpler-multimethods/pypy/objspace/std/tupleobject.py	Mon Feb  7 17:47:06 2005
@@ -29,10 +29,10 @@
     result = len(w_tuple.wrappeditems)
     return W_IntObject(space, result)
 
-def getitem__Tuple_Int(space, w_tuple, w_index):
+def getitem__Tuple_ANY(space, w_tuple, w_index):
     items = w_tuple.wrappeditems
     try:
-        w_item = items[w_index.intval]
+        w_item = items[space.int_w(w_index)]
     except IndexError:
         raise OperationError(space.w_IndexError,
                              space.wrap("tuple index out of range"))
@@ -64,14 +64,15 @@
     items2 = w_tuple2.wrappeditems
     return W_TupleObject(space, items1 + items2)
 
-def mul__Tuple_Int(space, w_tuple, w_int):
+def mul_tuple_times(space, w_tuple, times):
     items = w_tuple.wrappeditems
-    times = w_int.intval
-    return W_TupleObject(space, items * times)
+    return W_TupleObject(space, items * times)    
 
+def mul__Tuple_ANY(space, w_tuple, w_times):
+    return mul_tuple_times(space, w_tuple, space.int_w(w_times))
 
-def mul__Int_Tuple(space, w_int, w_tuple):
-    return mul__Tuple_Int(space, w_tuple, w_int)
+def mul__ANY_Tuple(space, w_times, w_tuple):
+    return mul_tuple_times(space, w_tuple, space.int_w(w_times))
 
 def eq__Tuple_Tuple(space, w_tuple1, w_tuple2):
     items1 = w_tuple1.wrappeditems



More information about the Pypy-commit mailing list