What would be better ?
time.sleep(delayTime)
or
select.select([],[],[],delayTime)
Are they equivalent ? Is select more efficient?
The answer depends on what your trying to achieve:
time.sleep(delayTime)
select.select([],[],[],delayTime)
This is a straightforward interface to the Unix select()
system call. The first three arguments are sequences of ‘waitable objects’:
So now, that we understand the two interfaces we can understand that the answer depends on the purpose:
If all you want to do is to suspend the current thread - the first option is simpler. But if there are objects to wait on - use the second method.
In temp of efficiency - I don't think there are differences if all you are looking for is the simplest use-case (just suspend the main thread).