Inconsistent Python Performance on Windows

前端 未结 2 611
抹茶落季
抹茶落季 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.

    0 讨论(0)
  • 2021-01-22 12:23

    I don't see anything problematic. You have code that performs serial IO, which will block your process and possibly invoke the scheduler. If that happens, it will first give control to a different process and only when that one yield or exceeds its timeslice it will re-schedule your process.

    The question for you is: What is the size of the scheduler timeslice of the systems you are running? I believe that this will give you an insight into what is happening.

    0 讨论(0)
提交回复
热议问题