How does CPython, behind the scenes, evaluate expressions like
args = (2,3)
print(*args)
?
The above obviously prints 2 3
, but what is CPython doing to make that appear? . Thus can I think of the *
operator applied to iterables as a kind of macro, that CPython when running simply replaces with the iterable contents?
NOTE TO ALL WHO WOULD LIKE TO MARK MY QUESTION IMMEDIATELY AS DUPLICATE (AS HAPPENED IN THE PAST): This question is not addressed by What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
That question addresses how *
behaves in all kinds of scenarios - I'm not interested in knowing that.
There there is also only a single mentioning of CPython (which doesn't address my concern).
I want to know **internally* how CPython treats the code pasted above. Can I think of the *
operator applied to iterables as a kind of macro, that CPython, when running, simply replaces with the iterable contents - or is CPython doing some more complex operation when parsing *args
in the scenario above?