[Python-checkins] r46183 - sandbox/trunk/decimal-c/decimal.py
georg.brandl
python-checkins at python.org
Wed May 24 17:15:10 CEST 2006
Author: georg.brandl
Date: Wed May 24 17:15:09 2006
New Revision: 46183
Modified:
sandbox/trunk/decimal-c/decimal.py
Log:
To do.
Modified: sandbox/trunk/decimal-c/decimal.py
==============================================================================
--- sandbox/trunk/decimal-c/decimal.py (original)
+++ sandbox/trunk/decimal-c/decimal.py Wed May 24 17:15:09 2006
@@ -2153,29 +2153,6 @@
_clamp - If 1, change exponents if too high (Default 0)
"""
- def __init__(self, prec=None, rounding=None,
- traps=None, flags=None,
- _rounding_decision=None,
- Emin=None, Emax=None,
- capitals=None, _clamp=0,
- _ignored_flags=None):
- if flags is None:
- flags = []
- if _ignored_flags is None:
- _ignored_flags = []
- if not isinstance(flags, dict):
- flags = dict([(s,s in flags) for s in _signals])
- del s
- if traps is not None and not isinstance(traps, dict):
- traps = dict([(s,s in traps) for s in _signals])
- del s
- for name, val in locals().items():
- if val is None:
- setattr(self, name, _copy.copy(getattr(DefaultContext, name)))
- else:
- setattr(self, name, val)
- del self.self
-
def __repr__(self):
"""Show the current context."""
s = []
@@ -2184,28 +2161,7 @@
s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']')
return ', '.join(s) + ')'
- def get_manager(self):
- return ContextManager(self.copy())
-
- def clear_flags(self):
- """Reset all flags to zero"""
- for flag in self.flags:
- self.flags[flag] = 0
-
- def _shallow_copy(self):
- """Returns a shallow copy from self."""
- nc = Context(self.prec, self.rounding, self.traps, self.flags,
- self._rounding_decision, self.Emin, self.Emax,
- self.capitals, self._clamp, self._ignored_flags)
- return nc
-
- def copy(self):
- """Returns a deep copy from self."""
- nc = Context(self.prec, self.rounding, self.traps.copy(), self.flags.copy(),
- self._rounding_decision, self.Emin, self.Emax,
- self.capitals, self._clamp, self._ignored_flags)
- return nc
- __copy__ = copy
+## FROM HERE
def _raise_error(self, condition, explanation = None, *args):
"""Handles an error
@@ -2247,19 +2203,6 @@
for flag in flags:
self._ignored_flags.remove(flag)
- def __hash__(self):
- """A Context cannot be hashed."""
- # We inherit object.__hash__, so we must deny this explicitly
- raise TypeError, "Cannot hash a Context."
-
- def Etiny(self):
- """Returns Etiny (= Emin - prec + 1)"""
- return int(self.Emin - self.prec + 1)
-
- def Etop(self):
- """Returns maximum exponent (= Emax - prec + 1)"""
- return int(self.Emax - self.prec + 1)
-
def _set_rounding_decision(self, type):
"""Sets the rounding decision.
@@ -2300,6 +2243,8 @@
self.rounding= type
return rounding
+## TO HERE
+
def create_decimal(self, num='0'):
"""Creates a new Decimal instance but using self as context."""
d = Decimal(num, context=self)
@@ -2774,9 +2719,7 @@
from _decimal import BasicContext, ExtendedContext, \
DefaultContext
-BasicContext.__class__ = Context
-ExtendedContext.__class__ = Context
-DefaultContext.__class__ = Context
+BasicContext._ignore_flags = Context._ignore_flags
class _WorkRep(object):
More information about the Python-checkins
mailing list