Performance with global variables vs local

后端 未结 4 613
囚心锁ツ
囚心锁ツ 2020-11-30 08:57

I am still new to Python, and I have been trying to improve the performance of my Python script, so I tested it with and without global variables. I timed it, and to my surp

4条回答
  •  萌比男神i
    2020-11-30 08:59

    The time that you are not including is the programmer time spent tracking down the bugs created when using a global has a side effect somewhere else in your program. That time is many times greater than the time spent creating and freeing local variables,

提交回复
热议问题