Martin Thoma
Martin Thoma

Reputation: 136307

Is time.sleep() a CPU bound operation?

I've recently read in this asyncio article

time.sleep() is a CPU bound operation

I usually connected with "CPU bound" that the CPU is actually doing something. So if one has time.sleep(60) in a program (A) and then executes

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

I always thought about timers being IO. Is that wrong? Or are timers just something special, so that they don't fit into the "IO-bound" / "CPU bound" schema?

Upvotes: 1

Views: 1105

Answers (2)

Dipen Shah
Dipen Shah

Reputation: 2444

Martin Thoma

No, it isn't CPU Bound.

Document Says.

You can also found similar information from here is a time sleep

Upvotes: 0

user2357112
user2357112

Reputation: 280456

It's not. That article is misusing terminology.

A CPU-bound operation is one whose speed is limited by the speed of CPU execution, as opposed to the speed of memory access or network round trips or some other factor. time.sleep is not such an operation. A faster CPU does not make time.sleep any faster.

Upvotes: 6

Related Questions