Skip to content

feat[next]: Add support for tuple comprehensions#2487

Open
SF-N wants to merge 14 commits into
GridTools:mainfrom
SF-N:tracer_support
Open

feat[next]: Add support for tuple comprehensions#2487
SF-N wants to merge 14 commits into
GridTools:mainfrom
SF-N:tracer_support

Conversation

@SF-N
Copy link
Copy Markdown
Contributor

@SF-N SF-N commented Feb 20, 2026

Adds support for tuple comprehensions, e.g. for usage on tracers.

@gtx.field_operator
def testee(
    tracers: tuple[cases.IField, cases.IField], factor: int32
) -> tuple[cases.IField, cases.IField]:
    return tuple(tracer * factor for tracer in tracers)

@tehrengruber tehrengruber changed the title feat[next]: Add support for tracers feat[next]: Add support for tuple comprehensions May 11, 2026
new_type = types[index]
case ts.VarArgType(element_type=element_type):
new_type = (
element_type # TODO: we only temporarily allow any index for vararg types
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for direct access to tracers[0] * factor, tracers[1] * factor, which I personally think is an anti pattern. I left it here until we take a decision on this. We could also make it an optional feature. One of the disadvantages is that it is not possible to fully type check the field operator at definition time, since the tuple length is only known at call / compile time. The user will then get an error in unroll_map_tuple.

@tehrengruber tehrengruber marked this pull request as ready for review May 11, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants