Inconsistent Python Performance on Windows

前端 未结 2 617
抹茶落季
抹茶落季 2021-01-22 12:05

I have some Python 2.7 code I\'m working on and it works great on any *nix type system. However, on windows the same section of code will have wildly different execution times.

2条回答
  •  再見小時候
    2021-01-22 12:17

    I believe that it is due to range. Older version of python (2.X) has both range and xrange for this purpose. But xrange is efficient than range since xrange generates the list only when it is needed (i.e, it returns a generator) while range generates the entire list(hence inefficient, suppose you have a list from 1 to 100000)

    So if your list size is increasing, the use of range could be the reason for your process being slowed down.

提交回复
热议问题