gh-148817: Fold long lists/sets of constant elements into constant tuples/frozensets (#149016)