[Answered ]-Celery signatures .s(): early or late binding?

1👍

So, according to your link, in this section:

partial() is early binding, whilst all the prior techniques are late
binding.

Early binding here means that function arguments are resolved when
calling partial()

At the risk of being pedantic, I would say that this is mixing terminology. Late/early binding applies to how free variables are evaluated when a function that creates a closures is called.

When you are talking about how arguments are evaluated during a function call, that’s different. For all function calls in python the arguments are evaluated fully when the function is called. That is a consequence of Python’s evaluation strategy, which is strict (also called greedy) as opposed to non-strict (also called lazy).

The strict/greed evaluation of function arguments is analogous to early-binding in closures. So using this way of phrasing it, yes, .s is "early binding".

That is, because my_func.s(param1, param2) is just a function call, then the arguments are eagerly evaluated.


Note, one example of a non-strict evaluation strategy is call-by-name. Languages like scala for an example) support call by name.

There is also Haskell, which has call-by-need, which is like a cached version fo call-by-name. Because Haskell is purely functional, and doesn’t allow variables to be re-assigned, you don’t see bugs like the ones you would be worried about though.

Leave a comment