Skip to content

Add subscript-style type annotations for Warp types #1216

Description

@shi-eric

Summary

Add support for subscript-style (bracket) type annotations on all core Warp types, enabling idiomatic Python type hints:

from typing import Literal

wp.array[float]                                  # 1D array
wp.array[float, Literal[2]]                      # 2D array
wp.array2d[float]                                # 2D array (shorthand)
wp.indexedarray[float]                           # 1D indexed array
wp.types.Vector[float, Literal[3]]               # vec3f
wp.types.Matrix[float, Literal[3], Literal[3]]   # mat33f
wp.types.Quaternion[float]                       # quatf
wp.types.Transformation[float]                   # transformf
wp.tile[float]                                   # tile (dtype-only)
wp.tile[float, Literal[8], Literal[4]]           # tile with shape

Design

  • dtype-first parameter order — aligns with NumPy ndarray[Dtype, Shape], C++ std::array<T, N>, Rust [T; N]
  • Instance-based returns — subscript results are the same objects as constructor/factory results, preserving compatibility with codegen's 68+ isinstance checks
  • Literal[] required for type checkers — bare integers work at runtime only
  • Tile shape is optional — wp.tile[dtype] for annotations, wp.tile[dtype, M, N] for forward compatibility

Parent issue

Sub-issue of #549

Activity

  1. added
    languageWarp syntax, types, annotations, inference, and kernel programming behavior
    on Feb 6, 2026
  2. self-assigned this
    on Feb 6, 2026
  3. added this to the 1.12.0 milestone on Feb 6, 2026
  4. shi-eric commented on Feb 15, 2026

    @shi-eric
    ContributorAuthor

    Added in b7b75e2

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

Metadata

Metadata

Assignees

Labels

languageWarp syntax, types, annotations, inference, and kernel programming behavior

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions