Hacker News new | ask | show | jobs
by maximilianroos 1585 days 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)

?
2 comments

Yes! 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/64bca66f14528cfda6d865cc2...

  partial(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.