summaryrefslogtreecommitdiffstats
path: root/Objects/floatobject.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-134584: Remove custom float decref ops (GH-142576)Ken Jin2025-12-151-7/+0
|
* gh-141004: soft-deprecate Py_INFINITY macro (#141033)Sergey B Kirpichev2025-11-121-1/+1
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-141042: fix sNaN's packing for mixed floating-point formats (#141107)Sergey B Kirpichev2025-11-121-4/+12
|
* GH-137623: Use an AC decorator for docstring line length enforcement (#137690)Adam Turner2025-08-181-2/+4
|
* gh-130821: Add type information to error messages for invalid return type ↵Semyon Moroz2025-08-141-4/+4
| | | | (GH-130835)
* gh-133304: workaround for RISC-V in PyFloat_Pack4/Unpack4() (#133328)Sergey B Kirpichev2025-05-031-0/+41
|
* gh-130317: Fix test_pack_unpack_roundtrip() and add docs (#133204)Sergey B Kirpichev2025-05-011-6/+4
| | | | | | * Skip sNaN's testing in 32-bit mode. * Drop float_set_snan() helper. * Use memcpy() workaround for sNaN's in PyFloat_Unpack4(). * Document, that sNaN's may not be preserved by PyFloat_Pack/Unpack API.
* gh-130317: Fix strict aliasing in PyFloat_Pack8() (#133150)Victor Stinner2025-04-291-7/+7
| | | | * Fix strict aliasing in PyFloat_Pack8() and PyFloat_Pack4(). * Fix _testcapi.float_set_snan() on x86 (32-bit).
* gh-130317: Fix PyFloat_Pack/Unpack[24] for NaN's with payload (#130452)Sergey B Kirpichev2025-04-281-7/+42
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-130704: Strength reduce `LOAD_FAST{_LOAD_FAST}` (#130708)mpage2025-04-011-31/+0
| | | Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
* GH-131238: More refactoring of core header files (GH-131351)Mark Shannon2025-03-171-0/+1
| | | | Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
* gh-111178: Change Argument Clinic signature for `@classmethod` (#131157)Victor Stinner2025-03-121-4/+4
| | | | Use "PyObject*", instead of "PyTypeObject*", for `@classmethod` functions to fix an undefined behavior.
* GH-127705: Use `_PyStackRef`s in the default build. (GH-127875)Mark Shannon2025-03-101-14/+17
|
* gh-111178: fix UBSan failures in `Objects/floatobject.c` (GH-129776)Bénédikt Tran2025-02-081-19/+24
| | | fix UBSan failures for `PyFloatObject`
* gh-128863: Deprecate _PyLong_Sign() function (#129176)Victor Stinner2025-01-231-1/+2
| | | Replace _PyLong_Sign() with PyLong_GetSign().
* gh-69639: Add mixed-mode rules for complex arithmetic (C-like) (GH-124829)Sergey B Kirpichev2024-11-261-6/+6
| | | | | | | | | | | | | | | "Generally, mixed-mode arithmetic combining real and complex variables should be performed directly, not by first coercing the real to complex, lest the sign of zero be rendered uninformative; the same goes for combinations of pure imaginary quantities with complex variables." (c) Kahan, W: Branch cuts for complex elementary functions. This patch implements mixed-mode arithmetic rules, combining real and complex variables as specified by C standards since C99 (in particular, there is no special version for the true division with real lhs operand). Most C compilers implementing C99+ Annex G have only these special rules (without support for imaginary type, which is going to be deprecated in C2y).
* GH-126547: Pre-assign version numbers for a few common classes (GH-126551)Mark Shannon2024-11-081-0/+1
|
* 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-125323: Convert DECREF_INPUTS_AND_REUSE_FLOAT into a function that takes ↵Mark Shannon2024-10-141-0/+35
| | | | PyStackRefs. (GH-125439)
* gh-123497: New limit for Python integers on 64-bit platforms (GH-123724)Serhiy Storchaka2024-09-291-7/+4
| | | | | | | | | | | Instead of be limited just by the size of addressable memory (2**63 bytes), Python integers are now also limited by the number of bits, so the number of bit now always fit in a 64-bit integer. Both limits are much larger than what might be available in practice, so it doesn't affect users. _PyLong_NumBits() and _PyLong_Frexp() are now always successful.
* gh-123990: Good bye WITH_FREELISTS macro (gh-124358)Donghee Na2024-09-241-8/+1
|
* gh-121485: Always use 64-bit integers for integers bits count (GH-121486)Serhiy Storchaka2024-08-301-8/+12
| | | | | Use 64-bit integers instead of platform specific size_t or Py_ssize_t to represent the number of bits in Python integer.
* gh-100240: Use a consistent implementation for freelists (#121934)Sam Gross2024-07-221-61/+7
| | | | | | | | This combines and updates our freelist handling to use a consistent implementation. Objects in the freelist are linked together using the first word of memory block. If configured with freelists disabled, these operations are essentially no-ops.
* gh-121905: Consistently use "floating-point" instead of "floating point" ↵Serhiy Storchaka2024-07-191-5/+5
| | | | (GH-121907)
* gh-84978: Add float.from_number() and complex.from_number() (GH-26827)Serhiy Storchaka2024-07-151-0/+31
| | | | | | They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
* gh-121562: optimized hex_from_char (#121563)Bruno Lima2024-07-141-62/+32
| | | | | Performance improvement to `float.fromhex`: use a lookup table for computing the hexadecimal value of a character, in place of the previous switch-case construct. Patch by Bruno Lima.
* gh-119057: Use better error messages for zero division (#119066)Nikita Sobolev2024-06-031-6/+5
|
* gh-119613: Use C99+ functions instead of Py_IS_NAN/INFINITY/FINITE (#119619)Sergey B Kirpichev2024-05-291-15/+15
|
* gh-116714: Handle errors correctly in `PyFloat_GetInfo` (#116715)Nikita Sobolev2024-03-131-8/+13
| | | Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-111968: Split _Py_dictkeys_freelist out of _Py_dict_freelist (gh-115505)Donghee Na2024-02-161-6/+6
|
* gh-111968: Rename freelist related struct names to Eric's suggestion (gh-115329)Donghee Na2024-02-141-19/+19
|
* gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists ↵Donghee Na2024-02-101-10/+0
| | | | (gh-114899)
* gh-111968: Use per-thread freelists for dict in free-threading (gh-114323)Donghee Na2024-02-011-0/+4
|
* gh-111968: Unify freelist naming schema to Eric's suggestion (gh-114581)Donghee Na2024-01-261-2/+2
|
* gh-111968: Explicit handling for finalized freelist (gh-113929)Donghee Na2024-01-121-4/+0
|
* gh-111968: Use per-thread freelists for float in free-threading (gh-113886)Donghee Na2024-01-101-27/+20
|
* Improve error message for "float modulo by zero" (#111685)Pavel Ovchinnikov2023-11-091-1/+1
|
* gh-108765: Python.h no longer includes <ctype.h> (#108831)Victor Stinner2023-09-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | Remove <ctype.h> in C files which don't use it; only sre.c and _decimal.c still use it. Remove _PY_PORT_CTYPE_UTF8_ISSUE code from pyport.h: * Code added by commit b5047fd01948ab108edcc1b3c2c901d915814cfd in 2004 for MacOSX and FreeBSD. * Test removed by commit 52ddaefb6bab1a74ecffe8519c02735794ebfbe1 in 2007, since Python str type now uses locale independent functions like Py_ISALPHA() and Py_TOLOWER() and the Unicode database. Modules/_sre/sre.c replaces _PY_PORT_CTYPE_UTF8_ISSUE with new functions: sre_isalnum(), sre_tolower(), sre_toupper(). Remove unused includes: * _localemodule.c: remove <stdio.h>. * getargs.c: remove <float.h>. * dynload_win.c: remove <direct.h>, it no longer calls _getcwd() since commit fb1f68ed7cc1536482d1debd70a53c5442135fe2 (in 2001).
* gh-106320: Remove private AC converter functions (#108505)Victor Stinner2023-08-261-0/+1
| | | | | | | | | | | | | | Move these private functions to the internal C API (pycore_abstract.h): * _Py_convert_optional_to_ssize_t() * _PyNumber_Index() Argument Clinic now emits #include "pycore_abstract.h" when these functions are used. The parser of the c-analyzer tool now uses a list of files which use the limited C API, rather than a list of files using the internal C API.
* gh-106320: Remove private _PyObject C API (#107147)Victor Stinner2023-07-231-1/+1
| | | | | | | | | | | | | | | | Move private debug _PyObject functions to the internal C API (pycore_object.h): * _PyDebugAllocatorStats() * _PyObject_CheckConsistency() * _PyObject_DebugTypeStats() * _PyObject_IsFreed() No longer export most of these functions, except of _PyObject_IsFreed(). Move test functions using _PyObject_IsFreed() from _testcapi to _testinternalcapi. check_pyobject_is_freed() test no longer catch _testcapi.error: the tested function cannot raise _testcapi.error.
* gh-106320: Create pycore_modsupport.h header file (#106355)Victor Stinner2023-07-031-0/+1
| | | | | | | | | | Remove the following functions from the C API, move them to the internal C API: add a new pycore_modsupport.h internal header file: * PyModule_CreateInitialized() * _PyArg_NoKwnames() * _Py_VaBuildStack() No longer export these functions.
* gh-104263: Rely on Py_NAN and introduce Py_INFINITY (GH-104202)Sebastian Berg2023-05-101-12/+1
| | | | | | | | | | 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-94673: Properly Initialize and Finalize Static Builtin Types for Each ↵Eric Snow2023-05-021-5/+4
| | | | | Interpreter (gh-104072) Until now, we haven't been initializing nor finalizing the per-interpreter state properly.
* gh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (gh-104054)Eric Snow2023-05-011-2/+2
| | | This also does some cleanup.
* gh-94673: Ensure Builtin Static Types are Readied Properly (gh-103940)Eric Snow2023-04-271-13/+3
| | | There were cases where we do unnecessary work for builtin static types. This also simplifies some work necessary for a per-interpreter GIL.
* gh-101825: Clarify that as_integer_ratio() output is always normalized (#101843)Sergey B Kirpichev2023-02-271-6/+4
| | | | | | | | | Make docstrings for `as_integer_ratio` consistent across types, and document that the returned pair is always normalized (coprime integers, with positive denominator). --------- Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-99537: Use Py_SETREF() function in C code (#99657)Victor Stinner2022-11-221-6/+3
| | | | | | | | | | | | | | | Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
* gh-81057: Move More Globals in Core Code to _PyRuntimeState (gh-99516)Eric Snow2022-11-161-10/+17
| | | https://github.com/python/cpython/issues/81057
* gh-99300: Use Py_NewRef() in Objects/ directory (#99335)Victor Stinner2022-11-101-9/+8
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
* gh-95605: Fix `float(s)` error message when `s` contains only whitespace ↵Mark Dickinson2022-08-101-1/+8
| | | | | (GH-95665) This PR fixes the error message from float(s) in the case where s contains only whitespace.