arxjit.reconcile

arxjit.reconcile

Source: packages/arxjit/src/arxjit/reconcile.py

title: Signature reconciliation for arxjit.
summary: >-
  Third stage of the arxjit pipeline: decide which Signature a validated
  function will be compiled against. An explicit signature= passed to @jit is
  the source of truth and wins outright; otherwise the signature is derived
  from the function's Python annotations; a function with neither is reported
  and stays interpreted. Annotations are read from the ast rather than from
  __annotations__ so that a module using "from __future__ import annotations"
  behaves identically, and so every diagnostic can point at the exact
  annotation that caused it. Following from that, ``int``, ``float`` and
  ``bool`` are reserved annotation spellings in a @jit function: they select
  i64, f64 and bool_ by name, independently of Python name resolution, so what
  those names are bound to where the function was defined does not change what
  the compiler is asked for. See _annotation_type for why resolving them
  through the defining namespace cannot be made sound.

Functions

resolve_signature(extracted: ExtractedSource, explicit: Signature | None=None) -> tuple[Signature | None, list[Diagnostic]]

title: Decide the Signature a validated function compiles against.
summary: >-
  An explicit signature decides the argument and return *types* outright
  and the annotations are not even read, so a function may annotate freely
  (or not at all) without having to agree with it; there is deliberately no
  type-mismatch error. It does not override the structure of the
  definition: the argument shape and the number of parameters are checked
  against the function first, on both paths, because those are facts rather
  than choices. Without an explicit signature, the annotations are used;
  int, float and bool are reserved spellings there, so see _annotation_type
  for why they are not resolved through the defining namespace. The
  returned signature is None exactly when the returned diagnostics are non-
  empty, which is the caller's signal that the function cannot be compiled.
parameters:
  extracted:
    type: ExtractedSource
    description: A function that has already passed validation.
  explicit:
    type: Signature | None
    description: The signature= passed to @jit, when given.
returns:
  type: tuple[Signature | None, list[Diagnostic]]
Back to top