Update of /cvsroot/python/python/nondist/sandbox/decimal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31119 Modified Files: Decimal.py Log Message: Int/long unification. Use int() everywhere. Only call long() when requested. Index: Decimal.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Decimal.py 30 Jun 2004 07:19:21 -0000 1.30 --- Decimal.py 30 Jun 2004 08:06:25 -0000 1.31 *************** *** 441,445 **** self._exp = value[2] else: ! self._exp = long(value[2]) return --- 441,445 ---- self._exp = value[2] else: ! self._exp = int(value[2]) return *************** *** 451,455 **** self._sign = 1 self._int = tuple(value.int) ! self._exp = long(value.exp) return --- 451,455 ---- self._sign = 1 self._int = tuple(value.int) ! self._exp = int(value.exp) return *************** *** 627,631 **** """ if self._exp >= 0: ! return hash(long(self)) else: return hash( (self._sign, self._int, self._exp) ) --- 627,631 ---- """ if self._exp >= 0: ! return hash(int(self)) else: return hash( (self._sign, self._int, self._exp) ) *************** *** 1365,1370 **** return float(str(self)) ! def __long__(self): ! """Converts self to a long, truncating if necessary.""" if self._isnan(): context = getcontext() --- 1365,1370 ---- return float(str(self)) ! def __int__(self): ! """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() *************** *** 1377,1383 **** if self._exp >= 0: s = sign + ''.join(map(str, self._int)) + '0'*self._exp ! return long(s) s = sign + ''.join(map(str, self._int))[:self._exp] ! return long(s) tmp = list(self._int) tmp.reverse() --- 1377,1383 ---- if self._exp >= 0: s = sign + ''.join(map(str, self._int)) + '0'*self._exp ! return int(s) s = sign + ''.join(map(str, self._int))[:self._exp] ! return int(s) tmp = list(self._int) tmp.reverse() *************** *** 1386,1397 **** val *= 10 val += tmp.pop() ! return long(((-1) ** self._sign) * val * 10.**int(self._exp)) ! def __int__(self): ! """Converts to a regular int. ! Equivalent to int(long(self)) """ ! return int(self.__long__()) def _fix(self, prec=None, rounding=None, folddown=None, context=None): --- 1386,1397 ---- val *= 10 val += tmp.pop() ! return int(((-1) ** self._sign) * val * 10.**int(self._exp)) ! def __long__(self): ! """Converts to a long. ! Equivalent to long(int(self)) """ ! return long(self.__int__()) def _fix(self, prec=None, rounding=None, folddown=None, context=None): *************** *** 1657,1661 **** sign = self._sign and not n._iseven() ! n = long(n) if self._isinfinity(): --- 1657,1661 ---- sign = self._sign and not n._iseven() ! n = int(n) if self._isinfinity(): *************** *** 2151,2159 **** def Etiny(self): """Returns Etiny (= Emin - prec + 1)""" ! return long(self.Emin - self.prec + 1) def Etop(self): """Returns maximum exponent (= Emin - prec + 1)""" ! return long(self.Emax - self.prec + 1) def _set_rounding_decision(self, type): --- 2151,2159 ---- def Etiny(self): """Returns Etiny (= Emin - prec + 1)""" ! return int(self.Emin - self.prec + 1) def Etop(self): """Returns maximum exponent (= Emin - prec + 1)""" ! return int(self.Emax - self.prec + 1) def _set_rounding_decision(self, type): *************** *** 2829,2833 **** exp = 0 else: ! exp = long(exp) intpart = m.group('int') --- 2829,2833 ---- exp = 0 else: ! exp = int(exp) intpart = m.group('int')