Parens do create a tuple

Chris Angelico rosuav at gmail.com
Sun Apr 10 23:02:21 EDT 2016


On Mon, Apr 11, 2016 at 12:51 PM, Random832 <random832 at fastmail.com> wrote:
> On Sun, Apr 10, 2016, at 22:32, Steven D'Aprano wrote:
>> def func(arg1, arg2, arg3):
>>     pass
>>
>> func(1, 2, 3)
>>
>> does not create a tuple (1, 2, 3) anywhere in its execution.
>
> Well, the second argument to PyObject_Call and function_call is a tuple,
> which had to come from somewhere. That may be a CPython implementation
> detail, but what else could __call__'s prototype be but (self, *args,
> **kwargs)?

On the arrivals side, sure, *args. But on the departures side, you can
use any sequence, and there's the whole thing of positional and
keyword arguments to look at. So ultimately, all you can possibly be
seeing is an implementation detail - there's no requirement that a
tuple ever be built.

ChrisA



More information about the Python-list mailing list