Guest User

Untitled

a guest
May 6th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1.  
  2. A_PLUS_B_TABLE = dict()
  3.  
  4. for i in range(256):
  5.     current = dict()
  6.     for j in range(256):
  7.         current[j] = i * j
  8.     A_PLUS_B_TABLE[i] = current
  9.  
  10.  
  11. def mulfast(x, y):
  12.     return A_PLUS_B_TABLE[x][y]
  13.  
  14.  
  15. def mulslow(x, y):
  16.     return x * y
  17.  
  18.  
  19. randtab1 = [randint(1, 255) for i in range(2000)]
  20.  
  21. randtab2 = [randint(1, 255) for i in range(2000)]
  22.  
  23. print(timeit(lambda: sum(map(mulfast, randtab1, randtab2)), number=NITERS))
  24. print(timeit(lambda: sum(map(mulslow, randtab1, randtab2)), number=NITERS))
  25.  
Advertisement
Add Comment
Please, Sign In to add comment