summaryrefslogtreecommitdiffstats
path: root/Modules/_decimal
Commit message (Collapse)AuthorAgeFilesLines
* gh-126133: Only use start year in PSF copyright, remove end years (#126236)Hugo van Kemenade2024-11-122-2/+2
|
* gh-121798: Add class method Decimal.from_number() (GH-121801)Serhiy Storchaka2024-10-142-0/+59
| | | | | | It is an alternate constructor which only accepts a single numeric argument. Unlike to Decimal.from_float() it accepts also Decimal. Unlike to the standard constructor, it does not accept strings and tuples.
* gh-124688: _decimal: Get module state from ctx for performance (#124691)neonene2024-09-281-48/+73
| | | Get a module state from ctx objects for performance.
* gh-124153: Remove `_PyType_GetModuleByDef2` private function (GH-124261)neonene2024-09-261-5/+13
| | | Thank you!
* chore: decimal module macro cleanup (#123791)Bénédikt Tran2024-09-091-78/+79
| | | | | | | | | | | | | * protect macros expansion via `do { ... } while (0)` constructions in `_decimal.c` * Use public macro `Py_UNUSED` This replaces the usages of the `UNUSED` macro which was not consistent with the `Py_UNUSED` macro itself. In addition, this amends the parameter names so that they match their semantic meanings. * Remove redundant `PyCFunction` casts
* gh-123657: Fix crash and refleak in `decimal.getcontext()` (GH-123703)neonene2024-09-061-10/+16
|
* gh-123243: Fix reference leak in `_decimal` (#123244)neonene2024-08-241-2/+24
|
* gh-122081: fixed crash in decimal.IEEEContext() (#122082)Sergey B Kirpichev2024-08-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | * gh-122081: fixed crash in decimal.IEEEContext() Now $ ./configure CFLAGS=-DEXTRA_FUNCTIONALITY -q && make -s && \ ./python -m test test_decimal - PASS * Apply suggestions from code review Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Update Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst * Apply suggestions from code review --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)Sergey B Kirpichev2024-05-291-2/+2
|
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-118379: Use PyTuple_Pack instead of Py_BuildValue if possible (GH-118381)Nice Zombies2024-04-301-2/+2
|
* gh-115119: Detect _decimal dependencies using pkg-config (#115406)Erlend E. Aasland2024-04-291-1/+13
| | | pkg-config is supported for libmpdec 4.0.0 and newer.
* gh-117578: Introduce _PyType_GetModuleByDef2 private function (GH-117661)neonene2024-04-251-5/+3
| | | | Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-113024: C API: Add PyObject_GenericHash() function (GH-113025)Serhiy Storchaka2024-03-221-1/+1
|
* gh-115119: Switch Windows build to mpdecimal external (GH-115182)Zachary Ware2024-03-181-0/+17
| | | | | This includes adding what should be a relatively temporary `Modules/_decimal/windows/mpdecimal.h` shim to choose between `mpdecimal32vc.h` or `mpdecimal64vc.h` based on which of `CONFIG_64` or `CONFIG_32` is defined.
* gh-108562: Fix compiler warnings for libmpdec (#114751)Sergey B Kirpichev2024-03-031-0/+1
| | | | | | If awailable, enable -fstrict-overflow for libmpdec. Also shut off false positive warnings (-Warray-bounds). The later was backported from mpdecimal-4.0.0.
* gh-114563: C decimal falls back to pydecimal for unsupported format strings ↵John Belmonte2024-02-121-122/+62
| | | | | | | | | | | | | | | | | | (GH-114879) Immediate merits: * eliminate complex workarounds for 'z' format support (NOTE: mpdecimal recently added 'z' support, so this becomes efficient in the long term.) * fix 'z' format memory leak * fix 'z' format applied to 'F' * fix missing '#' format support Suggested and prototyped by Stefan Krah. Fixes gh-114563, gh-91060 Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-114678: Fix incorrect deprecation warning for 'N' specifier in Decimal ↵Serhiy Storchaka2024-01-291-6/+8
| | | | | format (GH-114683) Co-authored-by: Stefan Krah <skrah@bytereef.org>
* gh-89902: Deprecate non-standard format specifier "N" for Decimal (GH-110508)Serhiy Storchaka2023-10-081-0/+6
| | | It was not documented and only supported in the C implementation.
* gh-106078: Suppress the warning caused by multi-phase initialization of ↵Charlie Zhao2023-10-061-1/+7
| | | | `decimal` (#107524)
* gh-109649: Use os.process_cpu_count() (#110165)Victor Stinner2023-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | Replace os.cpu_count() with os.process_cpu_count() in modules: * compileall * concurrent.futures * multiprocessing Replace os.cpu_count() with os.process_cpu_count() in programs: * _decimal deccheck.py test * freeze.py * multissltests.py * python -m test (regrtest) * wasm_build.py Other changes: * test.pythoninfo logs os.process_cpu_count(). * regrtest gets os.process_cpu_count() / os.cpu_count() in headers.
* gh-108346: Fix failed benchmark in decimal (#108353)Charlie Zhao2023-09-131-53/+74
| | | Fix benchmark in decimal to work again after the int str conversion limits.
* gh-108767: Replace ctype.h functions with pyctype.h functions (#108772)Victor Stinner2023-09-011-0/+1
| | | | | | | | | | | | | | Replace <ctype.h> locale dependent functions with Python "pyctype.h" locale independent functions: * Replace isalpha() with Py_ISALPHA(). * Replace isdigit() with Py_ISDIGIT(). * Replace isxdigit() with Py_ISXDIGIT(). * Replace tolower() with Py_TOLOWER(). Leave Modules/_sre/sre.c unchanged, it uses locale dependent functions on purpose. Include explicitly <ctype.h> in _decimal.c to get isascii().
* gh-106263: Fix segfault in `signaldict_repr` in `_decimal` module (#106270)Charlie Zhao2023-07-301-4/+28
| | | Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
* gh-106078: Isolate `decimal` module (#107287)Charlie Zhao2023-07-281-182/+269
|
* gh-86493: Modernize modules initialization code (GH-106858)Serhiy Storchaka2023-07-251-3/+2
| | | | | Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated PyModule_AddObject().
* gh-106078: Prepare to isolate decimal module (#106880)Charlie Zhao2023-07-201-21/+53
| | | | | | * move signal_map to global_state * move cond_map to global_state
* gh-86493: Fix possible leaks in modules initialization: _curses_panel, ↵Serhiy Storchaka2023-07-181-12/+12
| | | | _decimal, posix, xxsubtype (GH-106767)
* gh-106078: Move external C-API functions to decimal module global state ↵Charlie Zhao2023-07-111-23/+24
| | | | (#106616)
* gh-106078: Move static variables initialized once to decimal module global ↵Charlie Zhao2023-07-101-22/+28
| | | | state (#106475)
* gh-106078: Move static objects related to `CONTEXTVAR` to the decimal module ↵Charlie Zhao2023-07-081-28/+32
| | | | | | global state (#106395) Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-106078: Move `context template` to decimal module global state (#106346)Charlie Zhao2023-07-031-29/+30
|
* gh-106078: Move DecimalException to _decimal state (#106301)Charlie Zhao2023-07-021-8/+9
|
* gh-106078: Convert `_decimal` types to heap types (#106079)Charlie Zhao2023-06-291-383/+412
| | | | | | | | | | | | | | - Establish global state struct - Convert static types to heap types and add them to global state: * PyDecContextManager_Type * PyDecContext_Type * PyDecSignalDictMixin_Type * PyDec_Type - Add to global state: * PyDecSignalDict_Type * DecimalTuple Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-105375: Improve _decimal error handling (#105605)Erlend E. Aasland2023-06-111-1/+5
| | | Fix a bug where an exception could end up being overwritten.
* gh-92536: Remove PyUnicode_READY() calls (#105210)Victor Stinner2023-06-011-4/+0
| | | | Since Python 3.12, PyUnicode_READY() does nothing and always returns 0.
* GH-101291: Rearrange the size bits in PyLongObject (GH-102464)Mark Shannon2023-03-221-35/+8
| | | | | | | | | | * Eliminate all remaining uses of Py_SIZE and Py_SET_SIZE on PyLongObject, adding asserts. * Change layout of size/sign bits in longobject to support future addition of immortal ints and tagged medium ints. * Add functions to hide some internals of long object, and for setting sign and digit count. * Replace uses of IS_MEDIUM_VALUE macro with _PyLong_IsCompact().
* 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.