Python Glossary Русский

Python 3.12+Linuxsysfunction

sys.is_stack_trampoline_active()

debugging and tracing

Returns True if perf profiler trampolines are on — via activate_stack_trampoline() or by starting with -X perf. Linux only.

Syntax

sys.is_stack_trampoline_active()

Useful to avoid enabling trampolines twice and to learn whether the program was started with -X perf. It speaks only about perf: it knows nothing of cProfile, settrace or sys.monitoring. Like its neighbours, it exists only on Linux.

Examples

import subprocess, sys
if sys.platform == 'linux':
    code = 'import sys; print(sys.is_stack_trampoline_active())'
    print(sys.is_stack_trampoline_active())  # → False
    r = subprocess.run([sys.executable, '-X', 'perf', '-c', code],
                       capture_output=True, text=True, timeout=10)
    print(r.stdout.strip())  # → ? True — если сборка поддерживает perf

See also

Open in the full glossarydocs.python.orgReport an inaccuracy