MCPcopy Index your code
hub / github.com/python/cpython / int_divmod

Function int_divmod

Lib/_pylong.py:528–541  ·  view source on GitHub ↗

Asymptotically fast replacement for divmod, for 'int'. Its time complexity is O(n**1.58), where n = #bits(a) + #bits(b).

(a, b)

Source from the content-addressed store, hash-verified

526
527
528def int_divmod(a, b):
529 """Asymptotically fast replacement for divmod, for 'int'.
530 Its time complexity is O(n**1.58), where n = #bits(a) + #bits(b).
531 """
532 if b == 0:
533 raise ZeroDivisionError('division by zero')
534 elif b < 0:
535 q, r = int_divmod(-a, -b)
536 return q, -r
537 elif a < 0:
538 q, r = int_divmod(~a, b)
539 return ~q, b + ~r
540 else:
541 return _divmod_pos(a, b)
542
543
544# Notes on _dec_str_to_int_inner:

Callers

nothing calls this directly

Calls 1

_divmod_posFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…