summaryrefslogtreecommitdiffstats
path: root/Modules/_decimal
Commit message (Collapse)AuthorAgeFilesLines
* GH-101291: Refactor the `PyLongObject` struct into object header and ↵Mark Shannon2023-01-301-5/+5
| | | | PyLongValue struct. (GH-101292)
* gh-77532: Minor tweaks to allow compiling with PlatformToolset=ClangCL on ↵Steve Dower2023-01-271-0/+6
| | | | | | Windows (GH-101352) To use this, ensure that clang support was selected in Visual Studio Installer, then set the PlatformToolset environment variable to "ClangCL" and build as normal from the command line. It remains unsupported, but at least is possible now for experimentation.
* gh-99845: Use size_t type in __sizeof__() methods (#99846)Victor Stinner2022-11-301-5/+3
| | | | | | | | The implementation of __sizeof__() methods using _PyObject_SIZE() now use an unsigned type (size_t) to compute the size, rather than a signed type (Py_ssize_t). Cast explicitly signed (Py_ssize_t) values to unsigned type (Py_ssize_t).
* gh-99300: Use Py_NewRef() in Modules/ directory (#99466)Victor Stinner2022-11-141-72/+35
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in test C files of the Modules/ directory.
* gh-89653: Use int type for Unicode kind (#92704)Victor Stinner2022-05-131-2/+2
| | | | Use the same type that PyUnicode_FromKindAndData() kind parameter type (public C API): int.
* gh-89653: PEP 670: Convert PyUnicode_KIND() macro to function (#92705)Victor Stinner2022-05-131-6/+6
| | | | | | | | In the limited C API version 3.12, PyUnicode_KIND() is now implemented as a static inline function. Keep the macro for the regular C API and for the limited C API version 3.11 and older to prevent introducing new compiler warnings. Update _decimal.c and stringlib/eq.h for PyUnicode_KIND().
* gh-92584: test_decimal uses shutil.which() (#92640)Victor Stinner2022-05-101-2/+2
| | | | test_decimal now uses shutil.which() rather than deprecated distutils.spawn.find_executable().
* gh-91320: Use _PyCFunction_CAST() (#92251)Victor Stinner2022-05-031-38/+38
| | | | | | | | | | Replace "(PyCFunction)(void(*)(void))func" cast with _PyCFunction_CAST(func). Change generated by the command: sed -i -e \ 's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \ $(find -name "*.c")
* gh-91291: Accept attributes as keyword arguments in decimal.localcontext ↵Sam Ezeh2022-04-222-57/+95
| | | | | (#32242) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-45995: add "z" format specifer to coerce negative 0 to zero (GH-30049)John Belmonte2022-04-111-7/+119
| | | | | | | | Add "z" format specifier to coerce negative 0 to zero. See https://github.com/python/cpython/issues/90153 (originally https://bugs.python.org/issue45995) for discussion. This covers `str.format()` and f-strings. Old-style string interpolation is not supported. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* bpo-46361: Fix "small" `int` caching (GH-30583)Brandt Bucher2022-01-161-0/+7
|
* bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157)Christian Heimes2021-10-221-0/+3
| | | | | | | | | | | | | | setup.py no longer defines Py_BUILD_CORE_MODULE. Instead every module defines the macro before #include "Python.h" unless Py_BUILD_CORE_BUILTIN is already defined. Py_BUILD_CORE_BUILTIN is defined for every module that is built by Modules/Setup. The PR also simplifies Modules/Setup. Makefile and makesetup already define Py_BUILD_CORE_BUILTIN and include Modules/internal for us. Signed-off-by: Christian Heimes <christian@python.org>
* bpo-35134: Move classobject.h to Include/cpython/ (GH-28968)Victor Stinner2021-10-151-1/+0
| | | | | | | | | Move classobject.h, context.h, genobject.h and longintrepr.h header files from Include/ to Include/cpython/. Remove redundant "#ifndef Py_LIMITED_API" in context.h. Remove explicit #include "longintrepr.h" in C files. It's not needed, Python.h already includes it.
* pycore_pystate.h no longer redefines PyThreadState_GET() (GH-28921)Victor Stinner2021-10-131-13/+11
| | | | | | | | | | | | | | | | | | | | | | Redefining the PyThreadState_GET() macro in pycore_pystate.h is useless since it doesn't affect files not including it. Either use _PyThreadState_GET() directly, or don't use pycore_pystate.h internal C API. For example, the _testcapi extension don't use the internal C API, but use the public PyThreadState_Get() function instead. Replace PyThreadState_Get() with _PyThreadState_GET(). The _PyThreadState_GET() macro is more efficient than PyThreadState_Get() and PyThreadState_GET() function calls which call fail with a fatal Python error. posixmodule.c and _ctypes extension now include <windows.h> before pycore header files (like pycore_call.h). _PyTraceback_Add() now uses _PyErr_Fetch()/_PyErr_Restore() instead of PyErr_Fetch()/PyErr_Restore(). The _decimal and _xxsubinterpreters extensions are now built with the Py_BUILD_CORE_MODULE macro defined to get access to the internal C API.
* bpo-45332: Fix broken Decimal test and benchmark (GH-28680)Dong-hee Na2021-10-013-6/+3
|
* bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)Victor Stinner2021-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.
* 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-3024-116/+1967
| | | | | 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-214-276/+19
| | | | | | | | | 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-072-14/+5
| | | | | 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-012-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-40878: xlc cannot handle C99 extern inline. (GH-21887)Stefan Krah2020-08-151-1/+1
| | | This applies to the default "extc99" mode. Python does not compile with "stdc99".
* Catch all skip_handler cases (GH-21842)Stefan Krah2020-08-121-3/+3
|
* Call randseed() before other imports in deccheck.py (GH-21834)Stefan Krah2020-08-111-8/+8
|
* Replace import_fresh_module in decimal test files (GH-21815)Stefan Krah2020-08-103-12/+9
|
* bpo-41324 Add a minimal decimal capsule API (#21519)Stefan Krah2020-08-102-7/+252
|
* bpo-41369 Update to libmpdec-2.5.1: new features (GH-21593)Stefan Krah2020-07-222-0/+377
|
* bpo-41302: Fix build with system libmpdec (GH-21481)Felix Yan2020-07-152-6/+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-41100: fix _decimal for arm64 Mac OS (GH-21228)Lawrence D'Anna2020-06-301-0/+3
| | | Patch by Lawrence Danna.
* bpo-40874 Update the required libmpdec version for the decimal module (GH-21202)Stefan Krah2020-06-281-2/+2
|
* Add multicore support to deccheck.py. (GH-20731)Stefan Krah2020-06-081-21/+110
|
* bpo-40874: Update to libmpdec-2.5.0 (GH-20652)Stefan Krah2020-06-0538-296/+502
|
* 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-292-29/+176
|
* bpo-39576: Prevent memory error for overly optimistic precisions (GH-18581)Stefan Krah2020-02-212-6/+210
|
* Use the new recommended number of repetitions in the refleak tests. (#18569)Stefan Krah2020-02-201-1/+1
|
* Update runall.bat to the latest Windows build system. (#18571)Stefan Krah2020-02-201-41/+59
|
* Valgrind no longer supports --db-attach=yes. (#18568)Stefan Krah2020-02-201-1/+1
|
* 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().
* Revert mode change that loses information in directory listings on Linux. ↵Stefan Krah2019-08-211-0/+0
| | | | (#15366)
* Unmark files as executable that can't actually be executed. (GH-15353)Greg Price2019-08-211-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There are plenty of legitimate scripts in the tree that begin with a `#!`, but also a few that seem to be marked executable by mistake. Found them with this command -- it gets executable files known to Git, filters to the ones that don't start with a `#!`, and then unmarks them as executable: $ git ls-files --stage \ | perl -lane 'print $F[3] if (!/^100644/)' \ | while read f; do head -c2 "$f" | grep -qxF '#!' \ || chmod a-x "$f"; \ done Looking at the list by hand confirms that we didn't sweep up any files that should have the executable bit after all. In particular * The `.psd` files are images from Photoshop. * The `.bat` files sure look like things that can be run. But we have lots of other `.bat` files, and they don't have this bit set, so it must not be needed for them. Automerge-Triggered-By: @benjaminp
* Rename memory.c to mpalloc.c for consistency with the header file. (#14687)Stefan Krah2019-07-102-1/+1
|