How to generate exponentially increasing range in Python

前端 未结 8 1202
醉梦人生
醉梦人生 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:38

    Using a generator expression:

    max_exponent = 100
    for i in (10**n for n in xrange(1, max_exponent)):
        test(i)
    

提交回复
热议问题