Skip to content

TypedPython: numpy array parameters (types, warnings and division follow numpy scalars) #220

Open

Description

@b-re-w

Split from #149. array.array buffers compile zero-copy, but numpy arrays cannot simply reuse that path without breaking CPython identity. Verified with numpy 2.5.4 on 3.15t:

  • In the interpreter, element arithmetic produces numpy scalars (np.float64, np.int64, np.bool); s += v over the elements returns np.float64. Compiled code would return float.
  • numpy scalar ops emit RuntimeWarnings (overflow, invalid value), and division by zero warns instead of raising.

Design needed:

  • taint tracking of values derived from numpy elements;
  • boxing returned or escaping tainted values as the matching numpy scalar type;
  • reproducing numpy's floating-point warnings (FP exception flags turned into the same RuntimeWarning per operation site);
  • numpy's division semantics on tainted values.

Done when: compiled numpy functions match the interpreter in results, result types and emitted warnings (checked with warnings.catch_warnings(record=True)), and the nbody-style 7-array functions compile.

Activity

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