Skip to content

Generic slice list for improved type guarantees and speed - #1498

Open
TristonianJones wants to merge 1 commit into
cel-expr:masterfrom
TristonianJones:generic-list
Open

TristonianJones wants to merge 1 commit into
cel-expr:masterfrom
TristonianJones:generic-list

Conversation

@TristonianJones

@TristonianJones TristonianJones commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Introduce list generics for CEL to improve iteration performance.

Optimizations also applied to ext/lists.go with slice and reverse showing 50% gains in perf.

Subsequent PRs extend the approach to maps and native types.

#1293

Comment thread ext/lists.go
}

var newList []ref.Val
if sliced, ok := types.MaybeSliceList(types.DefaultTypeAdapter, list, int(start), int(end)); ok {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we add a test case that uses a custom adapter (Proto messages and/or NativeTypes)? I think ordinarily, we want the list to be propagating the same adapter configured from the top-level APIs

(Same ask for reverse)

Comment thread common/types/list.go
if list == nil {
return nil, false
}
val := list.Value()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add a few test cases around ensuring that we don't eagerly unwrap the values upon list adaptation here?

([optional.of(1), optional.none()]).reverse()[0] == optional.none()

// Something similar for `concatList`
([optional.of(1)] + [optional.none()]).reverse()[0] == optional.none()

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