arrayop-4-bytearray_map.py 370 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 = bytearray(b"\0" * 1000)
  9. arr2 = bytearray(map(lambda x: x + 1, arr))
  10. bench.run(test)