Martin McBride
Apr 27, 2022

One advantage is that it is declarative. If you use the partial function on another function, it is obvious what you are doing just by looking at the call. You will also know that it will probably work correctly because Python built-in functions don't usually have bugs.

If you implement a partial by calling your own defined function, then anyone reading the code has to go off and check your function to be sure exactly what it is doing.

It isn't a massive difference, it just makes your code that bit more readable.

One of the advantages of functional programming is that you often end up writing less code.

Martin McBride
Martin McBride

Responses (1)