On Sat, Mar 1, 2014 at 6:42 AM, Ron Adam <ron3200@gmail.com> wrote:
It's not clear what differences you mean here... can you show some examples?
These are exactly the same: x = (1,2) f(*x) f(1,2) I played with dis.dis() and it seems there are special-case opcodes for calling a function with a variable number of arguments and/or with variable keyword args; but once it arrives at the other side, the two are identical:
def f(*args): print(args) f(1,2) (1, 2) x=(1,2) f(*x) (1, 2)
The runtime fetches some callable, gives it some args, and says "Go do your stuff!". It doesn't care what that callable is - it could be a classic function defined with 'def' or 'lambda', it could be a type, it could be an object with __call__, it could be a built-in that's backed by a C function, anything. All that ends up arriving on the other side is: You have these positional args and these keyword args. Adding the tri-star to the mix suddenly changes that. A function is now capable of taking an expression, rather than an object. That's completely different, and it depends on the called function to distinguish one from the other. ChrisA