summaryrefslogtreecommitdiffstats
path: root/Modules/cmathmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-116738: Statically initialize special constants in cmath module (gh-142161)Alper2025-12-041-126/+99
| | | The initialization during `mod_exec` wasn't thread-safe with multiple interpreters.
* gh-141004: soft-deprecate Py_INFINITY macro (#141033)Sergey B Kirpichev2025-11-121-3/+3
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* GH-137623: Use an AC decorator for docstring line length enforcement (#137690)Adam Turner2025-08-181-2/+4
|
* gh-120026: soft deprecate Py_HUGE_VAL macro (#120027)Sergey B Kirpichev2024-11-011-1/+1
| | | Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* gh-122681: remove m_atan2()/c_atan2() helpers (#122715)Sergey B Kirpichev2024-08-171-2/+2
|
* gh-121268: Remove workarounds for non-IEEE 754 systems in cmath (#122716)Sergey B Kirpichev2024-08-091-14/+3
| | | | As now building Python now requires support of IEEE 754 floating point numbers.
* gh-122681: merge m_atan2() and c_atan2() helper functions (#122682)Sergey B Kirpichev2024-08-061-32/+2
|
* gh-122637: fix tanh(±0+infj) and tanh(±0+nanj) to return ±0+nanj (#122638)Sergey B Kirpichev2024-08-041-2/+2
| | | | | | | | | As per C11 DR#471, ctanh (0 + i NaN) and ctanh (0 + i Inf) should return 0 + i NaN (with "invalid" exception in the second case). This has corresponding implications for ctan(z), as its errors and special cases are handled as if the operation is implemented by -i*ctanh(i*z). This patch fixes cmath's code to do same. Glibs patch: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d15e83c5f5231d971472b5ffc9219d54056ca0f1
* gh-121889: cmath.acosh(0+nanj) returns nan+pi/2j (#121892)Sergey B Kirpichev2024-08-041-2/+2
| | | | | As per C11 DR#471 (adjusted resolution accepted for C17), cacosh (0 + iNaN) should return NaN ± i pi/2, not NaN + iNaN. This patch fixes cmath's code to do same.
* gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)Sergey B Kirpichev2024-05-291-37/+35
|
* 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-86493: Fix possible leaks in some modules initialization (GH-106768)Serhiy Storchaka2023-07-181-8/+7
| | | | Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time.
* gh-106320: Add pycore_complexobject.h header file (#106339)Victor Stinner2023-07-021-0/+1
| | | | | | Add internal pycore_complexobject.h header file. Move _Py_c_xxx() functions and _PyComplex_FormatAdvancedWriter() function to this new header file.
* gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)Sebastian Berg2023-05-101-55/+6
| | | | | | | | | | This PR removes `_Py_dg_stdnan` and `_Py_dg_infinity` in favour of using the standard `NAN` and `INFINITY` macros provided by C99. This change has the side-effect of fixing a bug on MIPS where the hard-coded value used by `_Py_dg_stdnan` gave a signalling NaN rather than a quiet NaN. --------- Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)Eric Snow2023-05-051-0/+1
| | | Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
* Few coverage nitpicks for the cmath module (#102067)Sergey B Kirpichev2023-02-221-2/+2
| | | | | | | | | | | - partial tests for cosh/sinh overflows (L535 and L771). I doubt both ||-ed conditions could be tested. - removed inaccessible case in sqrt (L832): ax=ay=0 is handled above (L823) because fabs() is exact. Also added test (checked with mpmath and gmpy2) for second condition on that line. - some trivial tests for isclose (cover all conditions on L1217-1218) - add comment for uncovered L1018 Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* Add missing 'is' to `cmath.log()` docstring (#102049)Owain Davies2023-02-191-2/+2
| | | Fix missing 'is' in cmath.log() docstring
* Revert "gh-89381: Fix invalid signatures of math/cmath.log (#101404)" (#101580)Mark Dickinson2023-02-051-5/+4
| | | This reverts commit 0ef92d979311ba82d4c41b22ef38e12e1b08b13d.
* gh-89381: Fix invalid signatures of math/cmath.log (#101404)Sergey B Kirpichev2023-01-291-4/+5
|
* bpo-46656: Remove Py_NO_NAN macro (GH-31160)Victor Stinner2022-02-251-2/+2
| | | | Building Python now requires support for floating point Not-a-Number (NaN): remove the Py_NO_NAN macro.
* bpo-45412: Add _PY_SHORT_FLOAT_REPR macro (GH-31171)Victor Stinner2022-02-231-7/+8
| | | | | | | | | | Remove the HAVE_PY_SET_53BIT_PRECISION macro (moved to the internal C API). * Move HAVE_PY_SET_53BIT_PRECISION macro to pycore_pymath.h. * Replace PY_NO_SHORT_FLOAT_REPR macro with _PY_SHORT_FLOAT_REPR macro which is always defined. gcc -Wundef emits a warning when using _PY_SHORT_FLOAT_REPR but the macro is not defined, if pycore_pymath.h include was forgotten.
* bpo-45548: Remove _math.c workarounds for pre-C99 libm (GH-29179)Christian Heimes2021-10-251-4/+6
| | | | | | | | | | | | | The :mod:`math` and :mod:`cmath` implementation now require a C99 compatible ``libm`` and no longer ship with workarounds for missing acosh, asinh, expm1, and log1p functions. The changeset also removes ``_math.c`` and moves the last remaining workaround into ``_math.h``. This simplifies static builds with ``Modules/Setup`` and resolves symbol conflicts. Co-authored-by: Mark Dickinson <mdickinson@enthought.com> Co-authored-by: Brett Cannon <brett@python.org> Signed-off-by: Christian Heimes <christian@python.org>
* bpo-43974: Move Py_BUILD_CORE_MODULE into module code (GH-29157)Christian Heimes2021-10-221-0/+4
| | | | | | | | | | | | | | 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-1635741: Port cmath to multi-phase init (PEP 489) (GH-22165)Mohamed Koubaa2020-09-101-30/+48
|
* bpo-35081: Move dtoa.h header to the internal C API (GH-18489)Victor Stinner2020-02-121-0/+1
| | | | | | | Move the dtoa.h header file to the internal C API as pycore_dtoa.h: it only contains private functions (prefixed by "_Py"). The math and cmath modules must now be compiled with the Py_BUILD_CORE macro defined.
* bpo-38835: Don't use PyFPE_START_PROTECT and PyFPE_END_PROTECT (GH-17231)Victor Stinner2019-11-201-11/+2
| | | | | The PyFPE_START_PROTECT() and PyFPE_END_PROTECT() macros are empty: they have been doing nothing for the last year (since commit 735ae8d139a673b30b321dc10acfd3d14f0d633b), so stop using them.
* bpo-37206: Unrepresentable default values no longer represented as None. ↵Serhiy Storchaka2019-09-141-4/+4
| | | | | | | (GH-13933) In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values (like in the optional third parameter of getattr). "None" should be used if None is accepted as argument and passing None has the same effect as not passing the argument at all.
* bpo-36908: 'This module is always available' isn't helpful. (#13297)Ned Batchelder2019-05-171-2/+2
| | | | Makes the documentation of math and cmath module more helpful for the beginners.
* Issue 23229: add cmath.inf, cmath.nan, cmath.infj and cmath.nanj.Mark Dickinson2016-08-291-0/+54
|
* Issue #12345: Add mathemathcal constant tau to math and cmath.Guido van Rossum2016-08-151-0/+1
| | | | Patch by Lisa Roach. See also PEP 628.
* Issue #27332: Fixed the type of the first argument of module-level functionsSerhiy Storchaka2016-07-071-52/+52
| | | | generated by Argument Clinic. Patch by Petr Viktorin.
* Issue #26305: Argument Clinic now escapes braces. No need to double them.Serhiy Storchaka2016-06-091-7/+7
|
* Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().Antoine Pitrou2015-06-231-1/+2
|\
| * Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().Antoine Pitrou2015-06-231-1/+2
| |
* | Issue #19543: Implementation of isclose as per PEP 485Tal Einat2015-05-311-0/+68
| | | | | | | | | | | | | | | | | | For details, see: PEP 0485 -- A Function for testing approximate equality Functions added: math.isclose() and cmath.isclose(). Original code by Chris Barker. Patch by Tal Einat.
* | Issue #23501: Argumen Clinic now generates code into separate files by default.Serhiy Storchaka2015-04-031-2/+1
| |
* | Regenerated Argument Clinic checksums.Serhiy Storchaka2015-02-201-3/+3
| |
* | Issue #21092: Merge from 3.4.Mark Dickinson2015-01-111-3/+3
|\ \ | |/
| * Issue #21902: Replace incorrect 'hyperbolic arc sine' (etc.) with 'inverse ↵Mark Dickinson2015-01-111-3/+3
| | | | | | | | hyperbolic sine' (etc.). Remove meaningless reference to radians.
* | Issue #20152: Convert the cmath module to Argument Clinic.Brett Cannon2014-10-141-222/+267
| |
* | Fix compilation failure (followup to #21803)Antoine Pitrou2014-07-071-3/+3
|/
* The function name for cmath.isinf in PyArg_ParseTuple() was wrong.Brett Cannon2014-01-311-1/+1
|
* Issue #18513: Add workaround for OS X 10.8 cexp bug that leads to wrong ↵Mark Dickinson2013-07-201-0/+7
| | | | cmath.rect(0.0,-0.0) results.
* #11565: Merge with 3.1.Ezio Melotti2011-03-161-1/+1
|\
| * #11565: Fix several typos. Patch by Piotr Kasprzyk.Ezio Melotti2011-03-161-1/+1
| |
| * Recorded merge of revisions 81032 via svnmerge fromAntoine Pitrou2010-05-091-810/+810
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines Recorded merge of revisions 81029 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........ ................
| * Merged revisions 74305 via svnmerge fromMark Dickinson2009-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@www.python.org/python/branches/py3k ................ r74305 | mark.dickinson | 2009-08-04 20:25:12 +0100 (Tue, 04 Aug 2009) | 9 lines Merged revisions 74303 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74303 | mark.dickinson | 2009-08-04 20:22:35 +0100 (Tue, 04 Aug 2009) | 2 lines Issue #6644: Fix compile error on AIX. ........ ................
* | Issue #9165: Add math.isfinite and cmath.isfinite.Mark Dickinson2010-07-111-0/+14
| |
* | Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-810/+810
| | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* | Merged revisions 76978 via svnmerge fromMark Dickinson2009-12-211-5/+6
| | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76978 | mark.dickinson | 2009-12-21 15:22:00 +0000 (Mon, 21 Dec 2009) | 3 lines Issue #7518: Move substitute definitions of C99 math functions from pymath.c to Modules/_math.c. ........