Python Glossary Русский

all Python 3gcfunction

gc.get_threshold()

thresholds and statistics

Returns the automatic collection thresholds — a tuple (threshold0, threshold1, threshold2).

Syntax

threshold0, threshold1, threshold2 = gc.get_threshold()

The defaults changed between versions: (700, 10, 10) up to 3.12 and (2000, 10, 10) from 3.13 — so do not hard-code them or compare them in tests. Save get_threshold before set_threshold so you can restore it: gc.set_threshold(*old) puts all three back.

Examples

import gc
print(gc.get_threshold())  # → ? (2000, 10, 10) на 3.13+, (700, 10, 10) раньше
print(len(gc.get_threshold()))  # → 3

See also

Open in the full glossarydocs.python.orgReport an inaccuracy