Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A_PLUS_B_TABLE = dict()
- for i in range(256):
- current = dict()
- for j in range(256):
- current[j] = i * j
- A_PLUS_B_TABLE[i] = current
- def mulfast(x, y):
- return A_PLUS_B_TABLE[x][y]
- def mulslow(x, y):
- return x * y
- randtab1 = [randint(1, 255) for i in range(2000)]
- randtab2 = [randint(1, 255) for i in range(2000)]
- print(timeit(lambda: sum(map(mulfast, randtab1, randtab2)), number=NITERS))
- print(timeit(lambda: sum(map(mulslow, randtab1, randtab2)), number=NITERS))
Advertisement
Add Comment
Please, Sign In to add comment