Skip to content

Returning a tuple instead of list for meshgrid to make it compliant with Array API #4034

Description

@aaishwarymishra

Hi, currently mlx.core.meshgrid returns a list. I am proposing to make it return tuple for making it compliant with Array API, and how numpy, and cupy do it.

Impact

Low risk of breaking real-world code. Common workflows are fully compatible with tuples:

  • Unpacking: X, Y = mx.meshgrid(x, y)

  • Indexing & Iteration: grids[0], for g in grids:

  • Direct passing: mx.stack(mx.meshgrid(...))

Only rare cases relying on isinstance(..., list) or container mutation (.append()) would be affected.

Activity

  1. JasonHonKL commented on Aug 6, 2026

    @JasonHonKL
    Contributor

    @aaishwarymishra mind if I fix this later ?

  2. aaishwarymishra commented on Aug 6, 2026

    @aaishwarymishra
    ContributorAuthor

    @JasonHonKL Hi, this issue is a proposal I wont get started until a maintainer first approves it as workable :)

  3. JasonHonKL commented on Aug 6, 2026

    @JasonHonKL
    Contributor

    sure no problem hahaha just having some spare time while searching for jobs lollll. But sure !

  4. ev-br commented on Aug 7, 2026

    @ev-br

    To expand on the numpy/array API history a bit: historically, numpy returned a list (and other array libraries followed, more or less). In NumPy 2.0, it was changed into returning a tuple. CuPy follows suit, and so does JAX (one reason for the backwards-incompatible change was I believe tuples are preferable in lazy/hit scenarios).
    Finally, Array API standard itself changed it in its 2025.12 revision.

  5. aaishwarymishra commented on Aug 7, 2026

    @aaishwarymishra
    ContributorAuthor

    Jax themselves recently merged it jax-ml/jax#39779 :)

  6. zcbenz commented on Aug 11, 2026

    @zcbenz
    Member

    Looks a nice change without hurting any existing code.

  7. aaishwarymishra commented on Aug 11, 2026

    @aaishwarymishra
    ContributorAuthor

    @JasonHonKL are you still interested to work on this ?

  8. JasonHonKL commented on Aug 11, 2026

    @JasonHonKL
    Contributor

    @aaishwarymishra yeah sure. A bit busy today gonna work on it tomorrow.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions