[pypy-svn] r77508 - pypy/branch/fast-forward/pypy/objspace/std

agaynor at codespeak.net agaynor at codespeak.net
Thu Sep 30 20:19:33 CEST 2010


Author: agaynor
Date: Thu Sep 30 20:19:31 2010
New Revision: 77508

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/floattype.py
   pypy/branch/fast-forward/pypy/objspace/std/inttype.py
Log:
Added int.conjugate and float.conjugate

Modified: pypy/branch/fast-forward/pypy/objspace/std/floattype.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/floattype.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/floattype.py	Thu Sep 30 20:19:31 2010
@@ -5,6 +5,7 @@
 from pypy.interpreter import gateway, typedef
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.interpreter.error import OperationError
+from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.strutil import ParseStringError
 from pypy.objspace.std.strutil import interp_string_to_float
@@ -13,6 +14,13 @@
 float_as_integer_ratio = SMM("as_integer_ratio", 1)
 float_hex = SMM("hex", 1)
 
+float_conjugate = SMM("conjugate", 1, doc="Returns self, the complex conjugate of any float.")
+
+def float_conjugate__ANY(space, w_float):
+    return space.pos(w_float)
+
+register_all(vars(), globals())
+
 
 def descr__new__(space, w_floattype, w_x=0.0):
     from pypy.objspace.std.floatobject import W_FloatObject

Modified: pypy/branch/fast-forward/pypy/objspace/std/inttype.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/inttype.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/inttype.py	Thu Sep 30 20:19:31 2010
@@ -1,6 +1,7 @@
 from pypy.interpreter import gateway, typedef
 from pypy.interpreter.error import OperationError
-from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.strutil import (string_to_int, string_to_w_long,
                                        ParseStringError,
                                        ParseStringOverflowError)
@@ -9,6 +10,13 @@
 
 # ____________________________________________________________
 
+int_conjugate = SMM("conjugate", 1, doc="Returns self, the complex conjugate of any int.")
+
+def int_conjugate__ANY(space, w_int):
+    return space.pos(w_int)
+
+register_all(vars(), globals())
+
 
 def wrapint(space, x):
     if space.config.objspace.std.withsmallint:
@@ -163,3 +171,4 @@
     real = typedef.GetSetProperty(descr_get_real),
     imag = typedef.GetSetProperty(descr_get_imag),
 )
+int_typedef.registermethods(globals())



More information about the Pypy-commit mailing list