1.1 --- a/lib/operator/augmented.py Fri Jan 25 23:12:44 2019 +0100
1.2 +++ b/lib/operator/augmented.py Fri Jan 25 23:24:33 2019 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Operator support.
1.6
1.7 -Copyright (C) 2010, 2013, 2015, 2017 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2010, 2013, 2015, 2017, 2019 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -22,7 +22,8 @@
1.13 from operator.core import augassign
1.14 from native import int_add, int_div, int_mod, int_mul, int_pow, int_sub, \
1.15 int_and, int_or, int_xor, \
1.16 - is_int
1.17 + is_int, \
1.18 + float_add, float_div, float_mul, float_pow, float_sub
1.19
1.20 # These functions defer method lookup by wrapping the attribute access in
1.21 # lambda functions. Thus, the appropriate methods are defined locally, but no
1.22 @@ -36,6 +37,8 @@
1.23 def iadd(a, b):
1.24 if is_int(a) and is_int(b):
1.25 return int_add(a, b)
1.26 + elif a.__class__ is float and b.__class__ is float:
1.27 + return float_add(a, b)
1.28 return augassign(a, b, lambda a: a.__iadd__, lambda a: a.__add__, lambda b: b.__radd__)
1.29
1.30 def iand_(a, b):
1.31 @@ -46,6 +49,8 @@
1.32 def idiv(a, b):
1.33 if is_int(a) and is_int(b):
1.34 return int_div(a, b)
1.35 + elif a.__class__ is float and b.__class__ is float:
1.36 + return float_div(a, b)
1.37 return augassign(a, b, lambda a: a.__idiv__, lambda a: a.__div__, lambda b: b.__rdiv__)
1.38
1.39 def ifloordiv(a, b):
1.40 @@ -62,6 +67,8 @@
1.41 def imul(a, b):
1.42 if is_int(a) and is_int(b):
1.43 return int_mul(a, b)
1.44 + elif a.__class__ is float and b.__class__ is float:
1.45 + return float_mul(a, b)
1.46 return augassign(a, b, lambda a: a.__imul__, lambda a: a.__mul__, lambda b: b.__rmul__)
1.47
1.48 def ior_(a, b):
1.49 @@ -72,6 +79,8 @@
1.50 def ipow(a, b):
1.51 if is_int(a) and is_int(b):
1.52 return int_pow(a, b)
1.53 + elif a.__class__ is float and b.__class__ is float:
1.54 + return float_pow(a, b)
1.55 return augassign(a, b, lambda a: a.__ipow__, lambda a: a.__pow__, lambda b: b.__rpow__)
1.56
1.57 def irshift(a, b):
1.58 @@ -80,6 +89,8 @@
1.59 def isub(a, b):
1.60 if is_int(a) and is_int(b):
1.61 return int_sub(a, b)
1.62 + elif a.__class__ is float and b.__class__ is float:
1.63 + return float_sub(a, b)
1.64 return augassign(a, b, lambda a: a.__isub__, lambda a: a.__sub__, lambda b: b.__rsub__)
1.65
1.66 def ixor(a, b):