Message 106431 - Python tracker
The implementation of 'round' for Python integers uses a round-to-nearest form of divmod: a, b -> q, r, where q is the nearest integer to a / b and r = a - b*q. This form of divmod would be useful elsewhere. In particular, it's currently needed for implementing multiplication and division of timedeltas by a float: see issue 1289118 . This patch exposes the operation to Python C code as _PyLong_Divmod_Near, and refactors long_round to use this operation.