News for hackers. Stuff that matters.
Re:Implementing Function Overloading in Python by joshuamorton on Thursday March 26, 2020 @03:10AM (#22691273)
Functions.singledispatch allows overloading based on the type of the first argument, but doesn't allow complex overloads, like arg-count based or multi-type based.
Re:Implementing Function Overloading in Python by emidln on Thursday March 26, 2020 @08:35AM (#22692879)
This is not hard to write if you care about it (dispatching on data in addition to dispatching on type). Clojure-style multimethods with python-style type dispatch or data result dispatch can be had for under 150 lines. It's not particularly useful unless you are porting code or otherwise writing very unpythonic code.