How to generate exponentially increasing range in Python

前端 未结 8 1248
醉梦人生
醉梦人生 2020-12-15 23:05

I want to test the performance of some code using an exponentially increasing value. So that as an extra digit is added to the numbers_size the increment is multiplied by 1

8条回答
  •  余生分开走
    2020-12-15 23:50

    To produce the same numbers as your code:

    numbers_sizes = (i*10**exp for exp in range(2, 9) for i in range(1, 10))
    for n in numbers_sizes:
        test(n)
    

提交回复
热议问题