summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
Commit message (Collapse)AuthorAgeFilesLines
* Issue #9136: Fix 'dictionary changed size during iteration'Mark Dickinson2010-07-081-15/+31
| | | | | | RuntimeError produced when profiling the decimal module. This was due to a dangerous iteration over 'locals()' in Context.__init__. (Backport of r82656 from release27-maint.)
* Fix Decimal speed issue; backport of r82652 from release27-maint.Mark Dickinson2010-07-081-9/+12
|
* Merged revisions 81350 via svnmerge fromStefan Krah2010-05-191-2/+2
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81350 | stefan.krah | 2010-05-19 17:46:39 +0200 (Wed, 19 May 2010) | 1 line Fix typos in docstrings. ........
* Merged revisions 80753 via svnmerge fromMark Dickinson2010-05-041-43/+83
| | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r80753 | mark.dickinson | 2010-05-04 15:25:50 +0100 (Tue, 04 May 2010) | 10 lines Issue #8567: Fix incorrect precedence of signals in Decimal module. When a Decimal operation raises multiple signals and more than one of those signals is trapped, the specification determines the order in which the signals should be handled. In many cases this order wasn't being followed, leading to the wrong Python exception being raised. This commit fixes those cases, and adds extra tests. The tests are only enabled when EXTENDEDERRORTESTS is True, since they involve rerunning each Decimal testcase several times. ........
* Merged revisions 77324 via svnmerge fromMark Dickinson2010-01-061-0/+7
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r77324 | mark.dickinson | 2010-01-06 16:20:22 +0000 (Wed, 06 Jan 2010) | 2 lines Add missing docstring for Context.divmod. Thanks Juan José Conti. ........
* Merged revisions 75943-75945 via svnmerge fromMark Dickinson2009-10-291-9/+30
| | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r75943 | mark.dickinson | 2009-10-29 11:09:09 +0000 (Thu, 29 Oct 2009) | 1 line Fix duplicate test numbers in extra.decTest ........ r75944 | mark.dickinson | 2009-10-29 12:04:00 +0000 (Thu, 29 Oct 2009) | 3 lines Issue #7233: A number of two-argument Decimal methods were failing to accept ints and longs for the second argument. ........ r75945 | mark.dickinson | 2009-10-29 12:11:18 +0000 (Thu, 29 Oct 2009) | 4 lines Issue #7233: Fix Decimal.shift and Decimal.rotate methods for arguments with more digits than the current context precision. Bug reported by Stefan Krah. ........
* Merged revisions 75561 via svnmerge fromMark Dickinson2009-10-271-1/+1
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r75561 | mark.dickinson | 2009-10-20 14:33:03 +0100 (Tue, 20 Oct 2009) | 3 lines Issue #7099: Decimal.is_normal should return True for all nonzero finite non-subnormal values, even those with exponent > Emax. ........
* Merged revisions 75275 via svnmerge fromMark Dickinson2009-10-271-1/+2
| | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r75275 | mark.dickinson | 2009-10-07 20:22:05 +0100 (Wed, 07 Oct 2009) | 6 lines Issue #7048: logb should round its result when that result doesn't fit into the available precision. (Tests for this change are included in the most recent set of testcases from the Decimal Specification site; those testcases will be updated shortly.) ........
* Merged revisions 74708 via svnmerge fromMark Dickinson2009-09-081-3/+2
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74708 | mark.dickinson | 2009-09-07 19:04:58 +0100 (Mon, 07 Sep 2009) | 2 lines #Issue 6795: Fix infinite recursion in long(Decimal('nan')); change int(Decimal('nan')) to raise ValueError instead of either returning NaN or raising InvalidContext. ........
* Merged revisions 74704 via svnmerge fromMark Dickinson2009-09-071-1/+1
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74704 | mark.dickinson | 2009-09-07 17:17:41 +0100 (Mon, 07 Sep 2009) | 3 lines Issue #6850: Fix bug in Decimal._parse_format_specifier for formats with no type specifier. ........
* Merged revisions 74564 via svnmerge fromMark Dickinson2009-08-281-2/+5
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74564 | mark.dickinson | 2009-08-28 14:25:02 +0100 (Fri, 28 Aug 2009) | 3 lines Issue #6794: Fix handling of NaNs in Decimal.compare_total and Decimal.compare_total_mag. ........
* Merged revisions 74281 via svnmerge fromMark Dickinson2009-08-021-17/+10
| | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74281 | mark.dickinson | 2009-08-02 11:59:36 +0100 (Sun, 02 Aug 2009) | 4 lines Issue #6595: Allow Decimal constructor to accept non-European decimal digits, as recommended by the specification. (Backport of r74279 from py3k.) ........
* Merged revisions 70430 via svnmerge fromMark Dickinson2009-03-171-2/+2
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r70430 | mark.dickinson | 2009-03-17 18:01:03 +0000 (Tue, 17 Mar 2009) | 3 lines Fix bug in Decimal __format__ method that swapped left and right alignment. ........
* Register decimals as numbers.NumberRaymond Hettinger2009-02-031-0/+7
|
* Merged revisions 68920 via svnmerge fromMark Dickinson2009-01-251-3/+15
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68920 | mark.dickinson | 2009-01-25 10:39:15 +0000 (Sun, 25 Jan 2009) | 2 lines Remove uses of cmp from the decimal module. ........
* Merged revisions 68317-68318 via svnmerge fromMark Dickinson2009-01-041-4/+4
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68317 | mark.dickinson | 2009-01-04 21:22:02 +0000 (Sun, 04 Jan 2009) | 2 lines More Python 2.3 compatibility fixes for decimal.py. ........ r68318 | mark.dickinson | 2009-01-04 21:25:40 +0000 (Sun, 04 Jan 2009) | 2 lines Misc/NEWS entry for r68317 ........
* Merged revisions 68191 via svnmerge fromMark Dickinson2009-01-031-56/+56
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68191 | mark.dickinson | 2009-01-03 12:07:20 +0000 (Sat, 03 Jan 2009) | 2 lines Issue #4812: further renaming of internal Decimal constants, for clarity. ........
* Merged revisions 68182 via svnmerge fromMark Dickinson2009-01-021-63/+63
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r68182 | mark.dickinson | 2009-01-02 23:07:08 +0000 (Fri, 02 Jan 2009) | 4 lines Issue #4812: add missing underscore prefix to some internal-use-only constants in the decimal module. (Dec_0 becomes _Dec_0, etc.) ........
* Merged revisions 67694 via svnmerge fromMark Dickinson2008-12-111-16/+16
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r67694 | facundo.batista | 2008-12-11 04:19:46 +0000 (Thu, 11 Dec 2008) | 6 lines Issue #4084: Fix max, min, max_mag and min_mag Decimal methods to give correct results in the case where one argument is a quiet NaN and the other is a finite number that requires rounding. Thanks Mark Dickinson. ........
* Fix:Neal Norwitz2008-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * crashes on memory allocation failure found with failmalloc * memory leaks found with valgrind * compiler warnings in opt mode which would lead to invalid memory reads * problem using wrong name in decimal module reported by pychecker Update the valgrind suppressions file with new leaks that are small/one-time leaks we don't care about (ie, they are too hard to fix). TBR=barry TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes) in opt mode: valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \ ./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \ -x test_logging test_ssl test_multiprocessing valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \ ./python -E -tt ./Lib/test/regrtest.py test_multiprocessing for i in `seq 1 4000` ; do LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \ ./python -c pass done At least some of these fixes should probably be backported to 2.5.
* Issue 2235: __hash__ is once again inherited by default, but inheritance can ↵Nick Coghlan2008-07-151-4/+2
| | | | be blocked explicitly so that collections.Hashable remains meaningful
* Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sureMark Dickinson2008-07-021-10/+10
| | | | | | | | that the behaviour of Decimal doesn't change if/when re.UNICODE becomes assumed in Python 3.0. Also add a check that alternative Unicode digits (e.g. u'\N{FULLWIDTH DIGIT ONE}') are *not* accepted in a numeric string.
* Make sure that Context traps and flags dictionaries have values 0 and 1Mark Dickinson2008-05-041-2/+2
| | | | (as documented) rather than True and False.
* Some very minor changes to decimal.py in Python 2.6, aimedMark Dickinson2008-05-041-9/+9
| | | | | | | | | | at reducing the size of the diff between the 2.x decimal.py and 3.x decimal.py and thereby making future merges easier: - replace one instnace of an old-style raise statement - define __div__ in terms of __truediv__ instead of the other way around - make wording match on an exception message
* Backport Raymond's changes in r60508 to Python 2.6.Mark Dickinson2008-05-031-4/+4
| | | | 'Context flags get set, not incremented'
* Fixed some test structures. Thanks Mark Dickinson.Facundo Batista2008-05-021-5/+1
|
* Issue #2482: Make sure that the coefficient of a DecimalMark Dickinson2008-03-251-3/+3
| | | | | instance is always stored as a str instance, even when that Decimal has been created from a unicode string.
* Issue #2478: Decimal(sqrt(0)) failed when the decimal contextMark Dickinson2008-03-251-3/+3
| | | | was not explicitly supplied.
* Fix docstring typo.Mark Dickinson2008-02-291-1/+1
|
* Add __format__ method to Decimal, to support PEP 3101Mark Dickinson2008-02-291-0/+240
|
* Remove duplicate 'import re' in decimal.pyMark Dickinson2008-02-241-2/+1
|
* Fix decimal repr which should have used single quotes like other reprs.Raymond Hettinger2008-02-141-242/+242
|
* Bring decimal a bit closer to the spec for Reals.Raymond Hettinger2008-02-121-0/+14
|
* Typos in decimal comment and documentationMark Dickinson2008-02-101-1/+1
|
* Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaNMark Dickinson2008-02-061-39/+110
| | | | raise InvalidOperation (and return False if InvalidOperation is trapped).
* Add support for trunc().Raymond Hettinger2008-01-241-0/+2
|
* Docstring typosAndrew M. Kuchling2008-01-161-3/+3
|
* Issue 1780: Allow leading and trailing whitespace in Decimal constructor,Mark Dickinson2008-01-121-3/+14
| | | | | when constructing from a string. Disallow trailing newlines in Context.create_decimal.
* Have Decimal.as_tuple return a named tuple.Raymond Hettinger2008-01-111-1/+7
|
* Issue #1757: The hash of a Decimal instance is no longer affectedFacundo Batista2008-01-081-3/+11
| | | | by the current context. Thanks Mark Dickinson.
* Some minor cleanups. Thanks Mark Dickinson.Facundo Batista2007-12-191-34/+19
|
* Removed the private _rounding_decision: it was not needed, and the codeFacundo Batista2007-12-171-94/+38
| | | | is now simpler. Thanks Mark Dickinson.
* fma speedup by avoiding to create a Context. Thanks Mark Dickinson.Facundo Batista2007-12-041-16/+31
|
* Faster _fix function, and some reordering for a more elegantFacundo Batista2007-12-031-52/+47
| | | | coding. Thanks Mark Dickinson.
* Speedup and cleaning of __str__. Thanks Mark Dickinson.Facundo Batista2007-12-031-71/+41
|
* Reordering of __new__ to minimize isinstance() calls to mostFacundo Batista2007-11-301-55/+56
| | | | used types. Thanks Mark Dickinson.
* Major change in the internal structure of the DecimalFacundo Batista2007-11-231-302/+219
| | | | | | | | | | number: now it does not store the mantissa as a tuple of numbers, but as a string. This avoids a lot of conversions, and achieves a speedup of 40%. The API remains intact. Thanks Mark Dickinson.
* The constructor from tuple was way too permissive: it allowed badFacundo Batista2007-10-191-10/+36
| | | | | | | | coefficient numbers, floats in the sign, and other details that generated directly the wrong number in the best case, or triggered misfunctionality in the alorithms. Test cases added for these issues. Thanks Mark Dickinson.
* Added a class to store the digits of log(10), so that they can be madeFacundo Batista2007-10-021-16/+49
| | | | available when necessary without recomputing. Thanks Mark Dickinson
* Made the various is_* operations return booleans. This was discussedFacundo Batista2007-10-021-112/+95
| | | | | | | | | | | with Cawlishaw by mail, and he basically confirmed that to these is_* operations, there's no need to return Decimal(0) and Decimal(1) if the language supports the False and True booleans. Also added a few tests for the these functions in extra.decTest, since they are mostly untested (apart from the doctests). Thanks Mark Dickinson