Skip to content

Commit e1dd12c

Browse files
committed
Some cleanup
1 parent 2cc39c9 commit e1dd12c

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

future/types/newint.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,24 @@ def __repr__(self):
9292
def __add__(self, other):
9393
value = super(newint, self).__add__(other)
9494
if value is NotImplemented:
95-
# e.g. a float, complex, ...
9695
return long(self) + other
9796
return newint(value)
9897

9998
def __radd__(self, other):
10099
value = super(newint, self).__radd__(other)
101100
if value is NotImplemented:
102-
# e.g. a float, complex, ...
103101
return other + long(self)
104102
return newint(value)
105103

106104
def __sub__(self, other):
107105
value = super(newint, self).__sub__(other)
108106
if value is NotImplemented:
109-
# e.g. a float, complex, ...
110107
return long(self) - other
111108
return newint(value)
112109

113110
def __rsub__(self, other):
114111
value = super(newint, self).__rsub__(other)
115112
if value is NotImplemented:
116-
# e.g. a float, complex, ...
117113
return other - long(self)
118114
return newint(value)
119115

@@ -134,23 +130,16 @@ def __rmul__(self, other):
134130
return value
135131

136132
def __div__(self, other):
137-
# We override this rather than e.g. relying on object.__div__ or
138-
# long.__div__ because we want to wrap the value in a newint()
139-
# call if other is another int
140133
value = long(self) / other
141-
if isinstance(other, (int, long)):
134+
if isint(value):
142135
return newint(value)
143-
elif value is NotImplemented:
144-
return long(self) / other
145136
else:
146137
return value
147138

148139
def __rdiv__(self, other):
149140
value = other / long(self)
150-
if isinstance(other, (int, long)):
141+
if isint(value):
151142
return newint(value)
152-
elif value is NotImplemented:
153-
return other / long(self)
154143
else:
155144
return value
156145

@@ -192,14 +181,12 @@ def __ifloordiv__(self, other):
192181
def __mod__(self, other):
193182
value = super(newint, self).__mod__(other)
194183
if value is NotImplemented:
195-
# e.g. a float, complex, ...
196184
return long(self) % other
197185
return newint(value)
198186

199187
def __rmod__(self, other):
200188
value = super(newint, self).__rmod__(other)
201189
if value is NotImplemented:
202-
# e.g. a float, complex, ...
203190
return other % long(self)
204191
return newint(value)
205192

0 commit comments

Comments
 (0)