summaryrefslogtreecommitdiffstats
path: root/Lib/_pydecimal.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-43475: Fix worst case collision behavior for NaN instances (GH-25493)Raymond Hettinger2021-04-221-1/+1
|
* Revert "bpo-26680: Incorporate is_integer in all built-in and standard ↵Raymond Hettinger2020-10-071-25/+0
| | | | | library numeric types (GH-6121)" (GH-22584) This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
* bpo-26680: Incorporate is_integer in all built-in and standard library ↵Robert Smallshire2020-10-011-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | numeric types (GH-6121) * bpo-26680: Adds support for int.is_integer() for compatibility with float.is_integer(). The int.is_integer() method always returns True. * bpo-26680: Adds a test to ensure that False.is_integer() and True.is_integer() are always True. * bpo-26680: Adds Real.is_integer() with a trivial implementation using conversion to int. This default implementation is intended to reduce the workload for subclass implementers. It is not robust in the presence of infinities or NaNs and may have suboptimal performance for other types. * bpo-26680: Adds Rational.is_integer which returns True if the denominator is one. This implementation assumes the Rational is represented in it's lowest form, as required by the class docstring. * bpo-26680: Adds Integral.is_integer which always returns True. * bpo-26680: Adds tests for Fraction.is_integer called as an instance method. The tests for the Rational abstract base class use an unbound method to sidestep the inability to directly instantiate Rational. These tests check that everything works correct as an instance method. * bpo-26680: Updates documentation for Real.is_integer and built-ins int and float. The call x.is_integer() is now listed in the table of operations which apply to all numeric types except complex, with a reference to the full documentation for Real.is_integer(). Mention of is_integer() has been removed from the section 'Additional Methods on Float'. The documentation for Real.is_integer() describes its purpose, and mentions that it should be overridden for performance reasons, or to handle special values like NaN. * bpo-26680: Adds Decimal.is_integer to the Python and C implementations. The C implementation of Decimal already implements and uses mpd_isinteger internally, we just expose the existing function to Python. The Python implementation uses internal conversion to integer using to_integral_value(). In both cases, the corresponding context methods are also implemented. Tests and documentation are included. * bpo-26680: Updates the ACKS file. * bpo-26680: NEWS entries for int, the numeric ABCs and Decimal. Co-authored-by: Robert Smallshire <rob@sixty-north.com>
* bpo-39794: Add --without-decimal-contextvar (#18702)Stefan Krah2020-02-291-2/+6
|
* bpo-36793: Remove unneeded __str__ definitions. (GH-13081)Serhiy Storchaka2019-05-061-2/+0
| | | | Classes that define __str__ the same as __repr__ can just inherit it from object.
* bpo-35133: Fix mistakes when concatenate string literals on different lines. ↵Serhiy Storchaka2018-11-051-1/+1
| | | | | | | | | | (GH-10284) Two kind of mistakes: 1. Missed space. After concatenating there is no space between words. 2. Missed comma. Causes unintentional concatenating in a list of strings.
* bpo-32630: Use contextvars in decimal (GH-5278)Yury Selivanov2018-01-271-11/+9
|
* Trivial cleanups following bpo-31370 (#3649)Antoine Pitrou2017-09-181-4/+1
| | | | | | * Trivial cleanups following bpo-31370 * Also cleanup the "importlib._bootstrap_external" module
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-64/+23
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-29776: Use decorator syntax for properties. (#585)Serhiy Storchaka2017-03-191-2/+2
|
* Fixed #29534 - _decimal difference with _pydecimal (#65)Andrew Nester2017-02-141-11/+16
|
* Issue #27348: Merge exception formatting fix from 3.5 into 3.6Martin Panter2016-09-221-1/+1
|\
| * Issue #27348: Restore “Exception: None” formatting in traceback moduleMartin Panter2016-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression caused by revision 73afda5a4e4c. Also reverts the decimal test workaround added in revision 5f3dd0a2b1ab. Remove test_without_exception(). According to revision ecaafc32c500, this was added in Python 2 so that print_exc() would output “None” when called with no exception set. However print_exc() never worked like this in Python 3, and the use case is not documented. Restore TracebackCases class name (instead of SyntaxTracebackCases), because the class also tests other exceptions.
* | Issue #26331: Implement the parsing part of PEP 515.Brett Cannon2016-09-091-5/+5
| | | | | | | | Thanks to Georg Brandl for the patch.
* | mergeRaymond Hettinger2016-08-131-6/+25
|\ \ | |/
| * Issue #27720: Fix error in eng_to_decimal docs and add examples from the ↵Raymond Hettinger2016-08-131-6/+25
| | | | | | | | | | | | specification. (Based on a first draft patch from Evelyn Mitchell.)
* | Issue #27171: Merge typo fixes from 3.5Martin Panter2016-06-021-1/+1
|\ \ | |/
| * Issue #27171: Fix typos in documentation, comments, and test function namesMartin Panter2016-06-021-1/+1
| |
* | Issue #26778: Fixed "a/an/and" typos in code comment, documentation and errorSerhiy Storchaka2016-04-171-1/+1
|\ \ | |/ | | | | messages.
| * Issue #26778: Fixed "a/an/and" typos in code comment and documentation.Serhiy Storchaka2016-04-171-1/+1
| |
* | Issue #26621: Update libmpdec version and remove unnecessary test case.Stefan Krah2016-03-231-1/+1
| |
* | Issue #25971: Optimized creating Fractions from floats by 2 times and fromSerhiy Storchaka2015-12-291-4/+2
| | | | | | | | | | | | Decimals by 3 times. Unified error messages in float.as_integer_ratio(), Decimal.as_integer_ratio(), and Fraction constructors.
* | Issue #25928: Add Decimal.as_integer_ratio(). Python parts and docs byStefan Krah2015-12-281-0/+52
|/ | | | Mark Dickinson.
* Issue #23641: Cleaned out legacy dunder names from tests and docs.Serhiy Storchaka2015-03-121-6/+5
| | | | | Fixed 2 to 3 porting bug in pynche.ColorDB. Added few tests for __truediv__, __floordiv__ and __matmul__.
* Remaining fallout from 17911Robert Collins2015-03-051-1/+1
| | | | | | | | | | | | | The code module was using a private function from traceback in order to skip a frame - used the direct interface to do that instead, The decimal module suffered minor fallout from formatting changes ('None' as a value is now not printed by traceback, the same as None was not before). The cgitb module was passing a bogus exception type (type.__name__) into format_exception, which uncovered that format_exception and print_exception had been ignoring the etype for some time, so the compatibility thunk to the new code now does the same thing.
* Issue #23326: Removed __ne__ implementations. Since fixing default __ne__Serhiy Storchaka2015-01-311-9/+0
| | | | implementation in issue #21408 they are redundant.
* Issue #19232: Fix sys.modules lookup (--without-threads)Stefan Krah2014-10-121-1/+2
|
* Issue #19232: Speed up decimal import. Additionally, since _decimal isStefan Krah2014-09-101-0/+6389
self-contained, this change facilitates maintenance and the Python version can be easily imported for experimentation.