Grant Edwards <invalid@invalid.invalid>:

> On 2015-09-11, Chris Angelico <ros...@gmail.com> wrote:
>> This is what I meant when I said you would be polling. Effectively,
>> you wake up your program every half-second, check if Ctrl-C has been
>> pressed, and if it hasn't, you go back to sleep again. This is pretty
>> inefficient.
>
> Though it offends one's engineering sensibilities[1], it's just not
> that inefficient. I'd bet money you won't even be able to measure the
> difference in CPU usage. Waking up twice per second and immediately
> calling select() again on any hardware/OS built in the past 50 years
> is going completely negligible (as long as you can ignore the smell).
>
> Even waking up ten times per second won't be noticeable.
>
> Waking up every millisecond or two might be noticeable.

It can add up. In particular, it can prevent the CPU from staying in the
low-power mode, especially on battery-powered devices.

  <URL: https://lwn.net/Articles/549580/>

Another environment where such polling circuses can actually overwhelm a
CPU is virtual machines. When dozens or hundreds of VMs are each polling
left and right, the host may not get much actual work done.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to