architecture

Guard and Deoptimisation

How type guards work and when deoptimisation happens.

Published May 30, 2026

Type Guards

Inline checks verify that variables still have expected types.

Guard Failure

If a type changes, execution jumps to the CPython interpreter.

Deoptimisation

The compiled function is marked deoptimised and may be recompiled with updated type info.

Monitoring

Deoptimisation counts are recorded in usage events.