summaryrefslogtreecommitdiffstats
path: root/Modules/_decimal/_decimal.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464) (GH-26465)Miss Islington (bot)2021-05-311-2/+1
| | | | | | | | | | | * _testcapi.heapgctype: implement a traverse function since the type is defined with Py_TPFLAGS_HAVE_GC. * _decimal: PyDecSignalDictMixin_Type is no longer defined with Py_TPFLAGS_HAVE_GC since it has no traverse function. (cherry picked from commit 142e5c5445c019542246d93fe2f9e195d3131686) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-43475: Fix worst case collision behavior for NaN instances (GH-25493)Raymond Hettinger2021-04-221-4/+1
|
* bpo-41369: Finish updating the vendored libmpdec to version 2.5.1 (GH-24962)Antoine Pitrou2021-03-301-2/+2
| | | | | Complete the update to libmpdec-2.5.1. Co-authored-by: Stefan Krah <skrah@bytereef.org>
* bpo-43422: Revert _decimal C API addition (GH-24960)Antoine Pitrou2021-03-211-193/+7
| | | | | | | | | Stefan Krah requested the reversal of these (unreleased) changes, quoting him: > The capsule API does not meet my testing standards, since I've focused on the upstream mpdecimal in the last couple of months. > Additionally, I'd like to refine the API, perhaps together with the Arrow community. Automerge-Triggered-By: GH:pitrou
* bpo-41798: Allocate _decimal extension module C API on the heap (GH-24117)Erlend Egeberg Aasland2021-01-061-5/+20
|
* bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)Victor Stinner2020-12-011-1/+1
| | | | | | | | | No longer use deprecated aliases to functions: * Replace PyObject_MALLOC() with PyObject_Malloc() * Replace PyObject_REALLOC() with PyObject_Realloc() * Replace PyObject_FREE() with PyObject_Free() * Replace PyObject_Del() with PyObject_Free() * Replace PyObject_DEL() with PyObject_Free()
* bpo-42006: Stop using PyDict_GetItem, PyDict_GetItemString and ↵Serhiy Storchaka2020-10-261-17/+30
| | | | | | | | | | | _PyDict_GetItemId. (GH-22648) These functions are considered not safe because they suppress all internal errors and can return wrong result. PyDict_GetItemString and _PyDict_GetItemId can also silence current exception in rare cases. Remove no longer used _PyDict_GetItemId. Add _PyDict_ContainsId and rename _PyDict_Contains into _PyDict_Contains_KnownHash.
* Revert "bpo-26680: Incorporate is_integer in all built-in and standard ↵Raymond Hettinger2020-10-071-4/+2
| | | | | 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-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-41324 Add a minimal decimal capsule API (#21519)Stefan Krah2020-08-101-7/+178
|
* bpo-41302: Fix build with system libmpdec (GH-21481)Felix Yan2020-07-151-0/+5
| | | | | | | Move definition of UNUSED from modified headers of libmpdec to _decimal.c itself. This makes the vendored source closer to the standalone library and fixes build with --with-system-libmpdec. Tested to build fine with either system libmpdec or the vendored one.
* bpo-40874 Update the required libmpdec version for the decimal module (GH-21202)Stefan Krah2020-06-281-2/+2
|
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-1/+0
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-40268: Remove explicit pythread.h includes (#19529)Victor Stinner2020-04-151-1/+0
| | | | Remove explicit pythread.h includes: it is always included by Python.h.
* bpo-39943: Add the const qualifier to pointers on non-mutable PyUnicode ↵Serhiy Storchaka2020-04-111-2/+2
| | | | data. (GH-19345)
* Cosmetic change to match the surrounding code. (#18704)Stefan Krah2020-02-291-1/+1
|
* bpo-39794: Add --without-decimal-contextvar (#18702)Stefan Krah2020-02-291-13/+156
|
* bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)Dong-hee Na2020-02-171-2/+2
|
* bpo-39573: Use Py_SET_SIZE() function (GH-18402)Victor Stinner2020-02-071-2/+2
| | | | Replace direct acccess to PyVarObject.ob_size with usage of the Py_SET_SIZE() function.
* bpo-39573: Use Py_TYPE() macro in Modules directory (GH-18393)Victor Stinner2020-02-071-3/+3
| | | Replace direct access to PyObject.ob_type with Py_TYPE().
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-8/+8
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-36793: Remove unneeded __str__ definitions. (GH-13081)Serhiy Storchaka2019-05-061-1/+1
| | | | Classes that define __str__ the same as __repr__ can just inherit it from object.
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-38/+38
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* bpo-34762: Update PyContext* to PyObject* in asyncio and decimal (GH-9609)Yury Selivanov2018-09-271-3/+3
| | | This fixes various compiler warnings.
* bpo-25988: Emit a warning when use or import ABCs from 'collections'. (#5460)Serhiy Storchaka2018-01-311-1/+5
|
* bpo-32630: Use contextvars in decimal (GH-5278)Yury Selivanov2018-01-271-89/+31
|
* bpo-31406: Fix crash due to lack of type checking in subclassing. (#3477)Stefan Krah2017-09-101-5/+14
|
* bpo-31403: Remove WITHOUT_THREADS from _decimal. (#3474)Stefan Krah2017-09-091-94/+1
|
* Correct typo (#976)Angus Hollands2017-04-031-1/+1
|
* Issue #28769: The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()Serhiy Storchaka2017-01-221-1/+1
| | | | is now of type "const char *" rather of "char *".
* While a speedup of 1% is measurable, contexts aren't created that often,Stefan Krah2017-01-091-4/+4
| | | | so let's defer this until 3.7, 3.8, ... all have this new function.
* Merge 3.6.Stefan Krah2017-01-091-7/+7
|\
| * Merge 3.5.Stefan Krah2017-01-091-7/+7
| |\
| | * Issue #28701: Revert part of 5bdc8e1a50c8 for the following reasons:Stefan Krah2017-01-091-7/+7
| | | | | | | | | | | | | | | | | | - There was no real problem to begin with. - The hypothetical problem has been fixed by 5bdc8e1a50c8.
* | | Revert part of dbf72357cb4a that is in a rarely used path and causesStefan Krah2017-01-071-1/+1
| | | | | | | | | | | | maintenance issues (cost/benefit).
* | | Revert (unauthorized) parts of 54a89144ee1d which are not in a speed-sensitiveStefan Krah2017-01-071-4/+4
| | | | | | | | | | | | path in order to avoid maintenance issues.
* | | Revert (unauthorized) parts of b9eb35435178 which are not in a speed-sensitiveStefan Krah2017-01-071-1/+1
| | | | | | | | | | | | path and cause maintenance issues (3.6 <-> 3.7, private test suite).
* | | Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka2016-12-161-1/+1
| | | | | | | | | | | | dict.
* | | Don't parenthesis in _PyObject_CallMethodId() formatVictor Stinner2016-12-081-1/+1
| | | | | | | | | | | | | | | Issue #28915: Without parenthesis, _PyObject_CallMethodId() avoids the creation a temporary tuple, and so is more efficient.
* | | Use _PyObject_CallNoArg()Victor Stinner2016-12-061-8/+8
|/ / | | | | | | | | | | | | Replace: PyObject_CallObject(callable, NULL) with: _PyObject_CallNoArg(callable)
* | Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-7/+7
|\ \ | |/ | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
| * Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-7/+7
| | | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
* | Issue #26331: Implement the parsing part of PEP 515.Brett Cannon2016-09-091-4/+8
| | | | | | | | Thanks to Georg Brandl for the patch.
* | Merge 3.5.Stefan Krah2016-07-171-8/+51
|\ \ | |/
| * Issue #26974: Fix segfault in the presence of absurd subclassing. ProactivelyStefan Krah2016-07-171-3/+47
| | | | | | | | eliminate all internal uses of overridden methods.
* | Merge 3.5.Stefan Krah2016-06-201-1/+1
|\ \ | |/
| * Issue #27006: Do not use PyDec_CheckExact() on a type.Stefan Krah2016-06-201-1/+1
| |
* | Merge 3.5.Stefan Krah2016-06-201-2/+8
|\ \ | |/
| * Issue #27006: from_float(): call the subclass' __new__() and __init__().Stefan Krah2016-06-201-2/+8
| |
* | Issue #26846: Post commit cleanup.Stefan Krah2016-04-261-1/+0
| |