summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix docstring bugRaymond Hettinger2007-02-081-1/+1
|
* Add missing word in commentNeal Norwitz2006-09-021-1/+1
|
* Make decimal.ContextManager a private implementation detail of ↵Nick Coghlan2006-09-021-24/+5
| | | | decimal.localcontext()
* Fix the wrongheaded implementation of context management in the decimal ↵Nick Coghlan2006-08-311-15/+65
| | | | module and add unit tests. (python-dev discussion is ongoing regarding what we do about Python 2.5)
* Revert r50706 (Whitespace normalization) andMartin v. Löwis2006-07-191-205/+184
| | | | | r50697: Comments and docs cleanups, and some little fixes per recommendation from Raymond Hettinger.
* Whitespace normalization.Tim Peters2006-07-181-6/+6
|
* Comments and docs cleanups, and some little fixes, provided by Santiágo ↵Facundo Batista2006-07-181-184/+205
| | | | Peresón
* Typo fix.Georg Brandl2006-05-111-1/+1
|
* Finish bringing SVN into line with latest version of PEP 343 by getting rid ↵Nick Coghlan2006-05-031-3/+3
| | | | of all remaining references to context objects that I could find. Without a __context__() method context objects no longer exist. Also get test_with working again, and adopt a suggestion from Neal for decimal.Context.get_manager()
* Get rid of __context__, per the latest changes to PEP 343 and python-devGuido van Rossum2006-05-021-1/+1
| | | | | | | | discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself.
* Move the PEP 343 documentation and implementation closer to theNick Coghlan2006-04-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | terminology in the alpha 1 documentation. - "context manager" reverts to its alpha 1 definition - the term "context specifier" goes away entirely - contextlib.GeneratorContextManager is renamed GeneratorContext There are still a number of changes relative to alpha 1: - the expression in the with statement is explicitly called the "context expression" in the language reference - the terms 'with statement context', 'context object' or 'with statement context' are used in several places instead of a bare 'context'. The aim of this is to avoid ambiguity in relation to the runtime context set up when the block is executed, and the context objects that already exist in various application domains (such as decimal.Context) - contextlib.contextmanager is renamed to contextfactory This best reflects the nature of the function resulting from the use of that decorator - decimal.ContextManager is renamed to WithStatementContext Simple dropping the 'Manager' part wasn't possible due to the fact that decimal.Context already exists and means something different. WithStatementContext is ugly but workable. A technically unrelated change snuck into this commit: contextlib.closing now avoids the overhead of creating a generator, since it's trivial to implement that particular context manager directly.
* Um, I thought I'd already checked this in.Guido van Rossum2006-03-101-2/+0
| | | | | | | Anyway, this is the changes to the with-statement so that __exit__ must return a true value in order for a pending exception to be ignored. The PEP (343) is already updated.
* Updates to the with-statement:Guido van Rossum2006-02-281-0/+29
| | | | | | | | | | | | | | | | - New semantics for __exit__() -- it must re-raise the exception if type is not None; the with-statement itself doesn't do this. (See the updated PEP for motivation.) - Added context managers to: - file - thread.LockType - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore} - decimal.Context - Added contextlib.py, which defines @contextmanager, nested(), closing(). - Unit tests all around; bot no docs yet.
* bug [ 1266296 ] Mistakes in decimal.Context.subtract documentationGeorg Brandl2005-08-221-1/+1
|
* Apply the _is_special guard.Raymond Hettinger2005-06-201-12/+13
|
* Minor namespace clean-up.Raymond Hettinger2005-06-071-2/+2
|
* * Fix decimal's handling of foreign types. Now returns NotImplementedRaymond Hettinger2005-03-271-4/+39
| | | | | | | instead of raising a TypeError. Allows other types to successfully implement __radd__() style methods. * Remove future division import from test suite. * Remove test suite's shadowing of __builtin__.dir().
* Bug #1163325: "special" decimals aren't hashableRaymond Hettinger2005-03-151-0/+4
|
* Fix small grammatical error in a docstring.Brett Cannon2005-03-011-1/+1
|
* Replace list of constants with tuples of constants.Raymond Hettinger2005-02-061-1/+1
|
* Bug #1083645Raymond Hettinger2004-12-181-2/+13
| | | | * The decimal module wouldn't load on builds without threads.
* SF bug #1071588 coercing decimal to int doesn't work between -1 and 1Raymond Hettinger2004-11-241-7/+7
|
* SF patch #1053375.Raymond Hettinger2004-10-271-63/+18
| | | | | | | | (Contributed by Facundo Batista.) Code simplification by eliminating the unnecessary and error-prone convolutions for the previously weird sign convention in _WorkRep(). Makes the code more understandable, more reliable, and a bit faster.
* Very few little improvements.Facundo Batista2004-10-261-10/+8
|
* SF bug #1048728: Bug fixes and cleanup for decimal.pyRaymond Hettinger2004-10-201-13/+7
| | | | (Contributed by Neal Norwitz. Reviewed by Facundo Bastista.)
* Don't use mutable values for method defaults.Raymond Hettinger2004-10-121-2/+6
|
* SF patch #1043218Raymond Hettinger2004-10-091-52/+39
| | | | | Simplify internal calls and logic for _fix() and _fixexponents(). (Contributed by Facundo Batista.)
* Use floor division operator.Raymond Hettinger2004-09-271-3/+3
|
* SF patch #1020845: Decimal performance enhancementsRaymond Hettinger2004-09-191-500/+437
| | | | | | | | | | | | (Contributed by Nick Coghlan.) Various code cleanups and optimizations (saves about 40% on testsuite execution time and on the telco benchmark). * caches results of various operations on self (esp. checks for being a special value). * _WorkRep now uses ints and longs for intermediate computations.
* Establish policies with respect to 2.3 compatibilty and treated specRaymond Hettinger2004-08-191-0/+9
| | | | updates as bugfixes.
* Revise max() and min() to comply with the 8/2/2004 update to the specificationRaymond Hettinger2004-08-171-19/+65
| | | | | | | | | | | (version 1.45): The max and min operations follow the rules in the current IEEE 754 revision draft: if one operand is a quiet NaN and the other is number, then the number is always returned if both operands are finite and equal in numerical value then an ordering is applied: if the signs differ then max returns the operand with the positive sign and min returns the operand with the negative sign; if the signs are the same then the exponent is used to select the result.
* * Context.copy() now makes a deepcopy.Raymond Hettinger2004-08-081-12/+21
| | | | * Facilitate reloads of local thread.
* SF bug #1002530: test_decimal fails if repeatedRaymond Hettinger2004-08-061-6/+8
| | | | | * Protect the pre-defined contexts by using a deepcopy() instead of copy(). * Micro-optimization: prefer x&1 over x%2
* Use threading.local() instead of threading.currentThread().Raymond Hettinger2004-07-141-21/+57
|
* Factor out two unnecessary global variables.Raymond Hettinger2004-07-141-11/+4
|
* * Hide a loop induction variable that was inadvertantly being picked upRaymond Hettinger2004-07-141-11/+2
| | | | | | | by the locals() call in the context constructor. * Remove unnecessary properties for int, exp, and sign which duplicated information returned by as_tuple().
* * Rename "Signals" to "_signals" making it non-public.Raymond Hettinger2004-07-141-7/+6
| | | | | * Context.create_decimal can take a zero default just like Decimal(). * Fix typo in comment.
* Improve Context construction and representation:Raymond Hettinger2004-07-101-27/+27
| | | | | | | | | | | | | * Rename "trap_enablers" to just "traps". * Simplify names of "settraps" and "setflags" to just "traps" and "flags". * Show "capitals" in the context representation * Simplify the Context constructor to match its repr form so that only the set flags and traps need to be listed. * Representation can now be run through eval(). Improve the error message when the Decimal constructor is given a float. The test suite no longer needs a duplicate reset_flags method.
* * Update the test suite to reflect that ConversionSyntax was no longerRaymond Hettinger2004-07-091-16/+4
| | | | | | | | public. * Removed the non-signal conditions from __all__. * Removed the XXX comment which was resolved. * Use ^ instead of operator.xor * Remove the threading lock which is no longer necessary.
* Module and tests:Raymond Hettinger2004-07-091-35/+30
| | | | | | | | | | | | * Map conditions to related signals. * Make contexts unhashable. * Eliminate used "default" attribute in exception definitions. * Eliminate the _filterfunc in favor of a straight list. Docs: * Eliminate documented references to conditions that are not signals. * Eliminate parenthetical notes such as "1/0 --> Inf" which are no longer true with the new defaults.
* Tim gets his default traps.Raymond Hettinger2004-07-081-8/+10
|
* Whitespace normalization.Tim Peters2004-07-071-5/+5
|
* * Add __eq__ and __ne__ so that things like list.index() work properlyRaymond Hettinger2004-07-051-4/+10
| | | | | for lists of mixed types. * Test that sort works.
* * Update the todo list.Raymond Hettinger2004-07-051-1/+2
| | | | * Make ConversionSyntax signals get trapped by default.
* * Fixup docstringsRaymond Hettinger2004-07-051-7/+6
| | | | * Make capitals default part of DefaultContext
* Changed the rounding constant values to match their variable names.Raymond Hettinger2004-07-041-32/+23
| | | | | | | | | | | | | | | | | | This serves to made the context representation more useful (the names in match the names out). Removed the link to ReXX. That document did not shed add anything to information already in the spec. Further tighten the public API to improve usability: * Emax and Emin are set through Context(). Their defaults are set in the DefaultContext, so there is no need to expose DEFAULT_MAX_EXPONENT and DEFAULT_MIN_EXPONENT. * The string functions isnan() and isinfinity() were only used internal to the module and were not among the test cases. External use cases are served by the Decimal constructor. So, made these private.
* Fix clear_flags(). Make a readable (not evalable) Context repr.Raymond Hettinger2004-07-041-1/+9
|
* Namespace cleanups:Raymond Hettinger2004-07-031-123/+126
| | | | | | | * delete temporary globals immediately after use * move a global into a class variable * Rename BasicDefaultContext and ExtendedDefaultContext to BasicContext and ExtendedContext.
* * Make the tests independent of the default precision.Raymond Hettinger2004-07-031-119/+120
| | | | * Change the default precision to 28 (to match VB's decimal type).
* Work through several open todos:Raymond Hettinger2004-07-031-43/+32
| | | | | | | | | | | | | | | | | * Added test for pickling contexts * Renamed ExceptionList to Signals (to match wording in the spec) * Simplified Context constructor by allowing flags=None to automatically generate a zeroed-out flags dictionary. * inlined _convertString() which was used only once * _rounding_decision is private, so excluded its contants from __all__. * added an XXX comment with concerns about subclassing signals results in a deviation from the spec (maybe important, maybe not). * Taught the test_suite to determine its own directory (modeled after code in regrtest.py). Enables it to be run when the current directory is not the test directory. * Added a clear_flags() method to the Context API to make it easier to do a common operation with flags. * Fixed the trap_enablers defaults in BasicDefaultContext to match the spec.