import random
import time
def f(max_a, max_b):
A = [random.randint(1, max_a) for _ in range(10 ** 6)]
B = [random.randint(1, max_b) for _ in range(10 ** 6)]
t0 = time.time()
for a, b in zip(A, B):
q, r = divmod(a, b)
t1 = time.time()
dm = divmod
for a, b in zip(A, B):
q, r = dm(a, b)
t2 = time.time()
for a, b in zip(A, B):
q, r = a // b, a % b
t3 = time.time()
for a, b in zip(A, B):
q = a // b; r = a - q * b
t4 = time.time()
print('[divmod] {:.4f}sec, [dm = divmod] {:.4f}sec, [// and %] {:.4f}sec, [// and -*] {:.4f}sec'.format(t1-t0, t2-t1, t3-t2, t4-t3))
f(1 << 8, 1 << 4)
f(1 << 32, 1 << 16)
f(1 << 64, 1 << 32)
f(10 ** 100, 10 ** 50)
f(10 ** 1000, 10 ** 500)