[issue37132] Add a module for integer related math functions

Serhiy Storchaka report at bugs.python.org
Sun Jun 2 07:39:07 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Actually it was ilog2. There was just an error in the documentation.

Currently we have two ways to represent the number as an integer ratio. The official way is two properties numerator and denominator, every number should have them. And some concrete numeric types have the as_integer_ratio() method which returns both values. Rather of adding as_integer_ratio() to all other numeric types I propose to add a helper function which uses either the as_integer_ratio() method if available, or  the numerator and denominator properties. Currently any code that uses the as_integer_ratio() method should implement a fallback to numerator and denominator. With imath.as_integer_ratio() it can just use this function.

> Radical suggestion: should we consider delaying the inclusions of `comb`, `perm` and `isqrt` in the math module so that we can do this properly for 3.9?

I like it. I suggest to delay also adding the int.as_integer_ratio() method. Currently it does not help because there are other numeric methods without the as_integer_ratio() method.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37132>
_______________________________________


More information about the Python-bugs-list mailing list