time.sleep() 是 CPU 绑定操作吗?

Is time.sleep() a CPU bound operation?

我最近读了 this asyncio article

time.sleep() is a CPU bound operation

我通常与 "CPU bound" 联系在一起 CPU 实际上正在做某事。因此,如果在程序 (A) 中有 time.sleep(60),然后执行

A: Gets 1 second
B: Gets 59 seconds (uninterrupted)
A: Finished or not?

我一直认为定时器就是 IO。那是错的吗?或者计时器只是一些特殊的东西,所以它们不适合 "IO-bound" / "CPU bound" 模式?

不是。那篇文章误用了术语。

CPU 绑定操作的速度受限于 CPU 执行速度,而不是内存访问或网络往返或其他一些因素的速度。 time.sleep 不是这样的操作。更快的 CPU 不会使 time.sleep 更快。

马丁·托马

不,它不是 CPU 绑定的。

Document 说。

您也可以从这里找到类似的信息is a time sleep