3 ms·
Great to see this! Thanks for working on it. Could you compare it to functools.partial? In the example on the Readme: import better_partial as bp @bp.
by maximilianroos 5y ago
Great to see this! Thanks for working on it.
Could you compare it to functools.partial?
In the example on the Readme:
import better_partial as bp
@bp.partial
def some_operation(x, p1, p2):
return (x + p1) * p2
It claims that the bp approach is superior because:
func = some_operation(bp._, 10, 20)
...is better than:
func = lambda x: some_operation(x, 10, 20)
But is it better than just:
partial(some_operation, p1=10, p2=20)
?
- R0b0t1 5y agopartial(some_operation, p1=10, p2=20) Suffers from inconsistent syntax compared to normal function call. This is probably a negative, but it could be a positive.
- cgrimm1994 5y agoYes! I definitely need to beef up the README. I wrote up a gist for some other commenters below which I can incorporate as part of the justification. https://gist.github.com/chrisgrimm/64bca66f14528cfda6d865cc21fe77d4 https://gist.github.com/chrisgrimm/64bca66f14528cfda6d865cc2...