1.1 --- a/lib/__builtins__/int.py Thu Sep 22 22:08:37 2016 +0200
1.2 +++ b/lib/__builtins__/int.py Thu Sep 22 22:15:50 2016 +0200
1.3 @@ -19,6 +19,7 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 +from __builtins__.operator import _binary_op, _negate
1.8 import native
1.9
1.10 class int(object):
1.11 @@ -135,24 +136,4 @@
1.12 "Return whether this int is non-zero."
1.13 return _negate(native._int_eq(self, 0))
1.14
1.15 -# Utility functions.
1.16 -
1.17 -def _binary_op(self, other, op):
1.18 -
1.19 - "Test the type of 'other' and perform 'op'."
1.20 -
1.21 - if self.__class__ is other.__class__:
1.22 - return op(self, other)
1.23 - else:
1.24 - return NotImplemented
1.25 -
1.26 -def _negate(result):
1.27 -
1.28 - "Negate any valid logical value."
1.29 -
1.30 - if result is NotImplemented:
1.31 - return result
1.32 - else:
1.33 - return not result
1.34 -
1.35 # vim: tabstop=4 expandtab shiftwidth=4