arrayop-2-list_map.py 352 B

123456789101112
  1. # Array operation
  2. # Type: list, map() call. This method requires allocation of
  3. # the same amount of memory as original array (to hold result
  4. # array). On the other hand, input array stays intact.
  5. import bench
  6. def test(num):
  7. for i in iter(range(num//10000)):
  8. arr = [0] * 1000
  9. arr2 = list(map(lambda x: x + 1, arr))
  10. bench.run(test)