Commit Graph

247 Commits

Author SHA1 Message Date
Victor Stinner
37834136d0 bpo-42161: Modules/ uses _PyLong_GetZero() and _PyLong_GetOne() (GH-22998)
Use _PyLong_GetZero() and _PyLong_GetOne() in Modules/ directory.

_cursesmodule.c and zoneinfo.c are now built with
Py_BUILD_CORE_MODULE macro defined.
2020-10-27 17:12:53 +01:00
Raymond Hettinger
497126f7ea Update link to supporting references (GH-22488) 2020-10-01 19:30:54 -07:00
Raymond Hettinger
438e9fc66f bpo-41513: Improve order of adding fractional values. Improve variable names. (GH-22368) 2020-09-22 20:01:12 -07:00
Raymond Hettinger
ec8a15b034 Make fractional value accumulation consistent inside and outside the loop. (GH-22315) 2020-09-18 17:57:28 -07:00
Raymond Hettinger
457d4e97de bpo-41513: Add docs and tests for hypot() (GH-22238) 2020-09-13 23:33:41 -07:00
Raymond Hettinger
67c998de24 bpo-41513: Expand comments and add references for a better understanding (GH-22123) 2020-09-06 15:10:07 -07:00
Raymond Hettinger
5b24d1592a Improve hypot() accuracy with three separate accumulators (GH-22032) 2020-09-01 22:00:50 -07:00
Raymond Hettinger
92c38164a4 Further improve accuracy of math.hypot() (GH-22013) 2020-08-30 10:00:11 -07:00
Raymond Hettinger
27de28607a bpo-41513: Save unnecessary steps in the hypot() calculation (#21994) 2020-08-29 09:11:04 -07:00
Raymond Hettinger
82e79480d6 Fix typos in comment (GH-21966) 2020-08-26 13:09:40 -07:00
Raymond Hettinger
8e19c8be87 bpo-41513: More accurate hypot() (GH-21916) 2020-08-24 17:40:08 -07:00
Raymond Hettinger
fff3c28052 bpo-41513: Improve speed and accuracy of math.hypot() (GH-21803) 2020-08-15 19:38:19 -07:00
Raymond Hettinger
930f4518ae On path with known exact float, extract the double with the fast macro. (GH-21072) 2020-06-23 11:45:25 -07:00
Niklas Fiekas
794e7d1ab2 bpo-29782: Consolidate _Py_Bit_Length() (GH-20739)
In GH-2866, _Py_Bit_Length() was added to pymath.h for lack of a better
location. GH-20518 added a more appropriate header file for bit utilities. It
also shows how to properly use intrinsics. This allows reconsidering bpo-29782.

* Move the function to the new header.
* Changed return type to match __builtin_clzl() and reviewed usage.
* Use intrinsics where available.
* Pick a fallback implementation suitable for inlining.
2020-06-15 14:33:48 +02:00
Serhiy Storchaka
5f4b229df7 bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443)
Previously, the result could have been an instance of a subclass of int.

Also revert bpo-26202 and make attributes start, stop and step of the range
object having exact type int.

Add private function _PyNumber_Index() which preserves the old behavior
of PyNumber_Index() for performance to use it in the conversion functions
like PyLong_AsLong().
2020-05-28 10:33:45 +03:00
Serhiy Storchaka
578c3955e0 bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636)
Only __index__ should be used to make integer conversions lossless.
2020-05-26 18:43:38 +03:00
Dong-hee Na
5be8241392 bpo-1635741: Port math module to multiphase initialization (GH-19243) 2020-03-31 16:33:22 +02:00
Zackery Spytz
5208b4b379 bpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)
In math_2(), the first PyFloat_AsDouble() call should be checked
for failure before the second call.

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2020-03-14 10:45:32 +00:00
Serhiy Storchaka
559e7f165a bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. (GH-18604)
* bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments.

* Simplify fast path.

* Difine lcm() without arguments returning 1.

* Apply suggestions from code review

Co-Authored-By: Mark Dickinson <dickinsm@gmail.com>

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2020-02-23 11:21:29 +00:00
ananthan-123
f2ee21d858 bpo-39479:Add math.lcm() function: Least Common Multiple (#18547)
* Update math.rst

* Update math.rst

* updated whats new

* Update test_math.py

* Update mathmodule.c

* Update mathmodule.c.h

* Update ACKS

* 📜🤖 Added by blurb_it.

* Update 3.9.rst

* Update 2020-02-18-12-37-16.bpo-39479.j3UcCq.rst

* Update math.rst

* Update 2020-02-18-12-37-16.bpo-39479.j3UcCq.rst

* Update test_math.py

* Update ACKS

* Update mathmodule.c.h

* Update mathmodule.c

* Update mathmodule.c.h

* Update mathmodule.c.h

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2020-02-19 18:21:37 +00:00
Victor Stinner
e9e7d284c4 bpo-35081: Move dtoa.h header to the internal C API (GH-18489)
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.
2020-02-12 22:54:42 +01:00
Victor Stinner
85ead4fc62 bpo-39396: Fix math.nextafter(-0.0, +0.0) on AIX 7.1 (GH-18094)
Move also math.nextafter() on math.ulp() tests from IsCloseTests to
MathTests.
2020-01-21 11:14:10 +01:00
Niklas Fiekas
c5b79003f5 bpo-31031: Unify duplicate bits_in_digit and bit_length (GH-2866)
Add _Py_bit_length() to unify duplicate bits_in_digit() and bit_length().
2020-01-16 15:09:19 +01:00
Victor Stinner
0b2ab21956 bpo-39310: Add math.ulp(x) (GH-17965)
Add math.ulp(): return the value of the least significant bit
of a float.
2020-01-13 12:44:35 +01:00
Victor Stinner
100fafcf20 bpo-39288: Add math.nextafter(x, y) (GH-17937)
Return the next floating-point value after x towards y.
2020-01-12 02:15:42 +01:00