math.div(a, b, integer=True, round='up')
is verbose enough that the practice of writing wrappers would not end; my purpose in suggesting this is to eliminate duplicative, inconsistent wrappers.
For completeness, the division variants I have personally seen in use, not counting specialized numerical libraries, are the one called /
in python, the one called //
in python, the integer-ceiling-division one we are discussing here, and “exact integer division”:
def exact_integer_divide(x, y):
q, r = divmod(x, y)
if r:
raise ArithmeticError(f"Inexact division: {x} % {y} = {r}")
return q
I’m less enthusiastic about adding that to the standard library.
After seeing the discussion above, I’m convinced on the math.ceildiv
name. The two places I’m aware of in the python standard library with conceptually-related functions are math
(gcd
, isqrt
, lcm
) and built-ins (divmod
, max
, sum
, etc.). And I don’t think crowding the global namespace is a good idea.