I don’t like that the proposal requires a kwarg, but I don’t know that the alternatives are any better.
I think the distinction of itemsgetter would be easily overlooked. I don’t mind it having a longer name tuple_itemgetter may be a bit verbose, but nobody should be overlooking an s with it. could also have itemgetter.as_tuple, but that has it’s own awkwardness.
The kwarg is fine, it’s not what I would prefer, but it would be usable.
The “always” seems inappropriate. Any itemgetter already always gives tuples or always gives single values. No itemgetter sometimes gives tuples and sometimes doesn’t. Unless you mean an itemgetter with one index and the source values sometimes happen to already be tuples and sometimes happen to be non-tuples, and the always_tuple is supposed to wrap the latter in tuples but not do that with the former?
No strong feelings on whether this should be supported, but I think unwrap is a better kwarg, with default value True.
Side note about that PR: It is doing a lot of things; if I received a PR like that, I would probably ask the contributor to break it up into individual improvements that can be reviewed in isolation. So if your plan is to modify the signature/behavior of itemgetter, I would probably not try to do so in that PR.
Ideally, it was named itemsgetter, then it would be clear that it calls __getitem__ many times and stores them in a tuple, while currently it is an object which is meant to do both single and multiple accessing and is named after single. This design makes it fairly difficult to add features to it.
Btw, I don’t like the fact that this requires kwarg either, but as of now I can not see better alternatives. Except one backward-compatibility breaking change:
Having 2 separate itemgetter and itemsgetter would make things more robust and life easier going forward. I even think that making this change now would be worthwhile.