On Sat, Aug 15, 2020 at 09:25:00PM -0700, Stephan Hoyer wrote:
One question that comes up: should d[**kwargs] be valid syntax? d[*args] currently is not, but that's OK since d[tuple(args)] is identical.
If we're going to support keyword arguments, what reason would we have for not supporting `**kw` unpacking?
On the other hand, we probably do need d[**kwargs] since there's no way to dynamically unpack keyword arguments (short of directly calling __getitem__).
Indeed. So there is an excellent reason to support keyword unpacking, and no good reason not to support it. (Assuming keyword args are supported at all.)
And perhaps for symmetry this suggests d[*args] should be valid, too, defined as equivalent to d[tuple(args)].
Since positional arguments to `__getitem__` are automatically packed into a single argument, there is no need to call it with `*args`. That would be a waste of time: have the interpreter unpack the arguments, then pack them again. As you say, that makes it functionally equivalent to just passing `tuple(args)`.
"For symmetry" is at best a weak argument.