Python Glossary Русский

Python 3.2+sysfunction

sys.getswitchinterval()

interpreter

Returns the thread switch interval in seconds (0.005 by default): how often the interpreter asks a thread to hand the GIL to another one.

Syntax

sys.getswitchinterval()

It is neither a time slice nor a guarantee: a thread busy in a long C operation releases the GIL only when it finishes. The interval does not make threads compute in parallel — with the GIL, pure-Python work still takes turns. It has nothing to do with asyncio, where tasks switch only at await.

Examples

import sys
print(sys.getswitchinterval())  # → 0.005
print(sys.getswitchinterval() * 1000, 'мс')  # → 5.0 мс

See also

Open in the full glossarydocs.python.orgReport an inaccuracy