Skip to content

TypedPython: depth precheck, fast entry and inlining for acyclic callees (spectral-norm) #147

Closed

Description

@b-re-w

Approved by the user (2026-10-04) from docs/investigations/typedpython-vs-cython-numba-lpython.md. spectral-norm is 6.3x (M2 needs 10x, #41); its hot path is a leaf call per inner iteration paying tp_enter_call/tp_leave_call.

Design (agreed in #41): a callee outside every call cycle adds at most k frames (k static). A precheck depth + k <= limit at the cycle entry or wrapper selects a fast entry without enter/leave, so the C compiler can inline it. If the precheck fails, the call runs the normal per-call path, never an early RecursionError.

Done when: tests compare with the interpreter at every depth between limit-k and limit (result, RecursionError, and at which call); a mutation that takes the fast path despite a failed precheck fails them; spectral-norm re-measured (interleaved, quiet window).

Activity

  1. added 2 commits that reference this issue on Oct 17, 2026
  2. b-re-w commented on Oct 17, 2026

    @b-re-w
    MemberAuthor

    Landed in develop via #210. spectral-norm 5.6x -> 59.4x against CPython (interleaved, quiet window).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions