arrayop-1-list_inplace.py 316 B

123456789101112
  1. # Array operation
  2. # Type: list, inplace operation using for. What's good about this
  3. # method is that it doesn't require any extra memory allocation.
  4. import bench
  5. def test(num):
  6. for i in iter(range(num//10000)):
  7. arr = [0] * 1000
  8. for i in range(len(arr)):
  9. arr[i] += 1
  10. bench.run(test)