That was way easier than expected...
This is an experimental library, for enabling dynamic dispatch in Python.
It has no dependencies other than the standard library.
import dyndispatch
@dyndispatch.overload
def thing(a, b, c):
return "V1"
@dyndispatch.overload
def thing(a, b, c, d):
return "V2"
assert thing(1, 2, 3, 4) == "V2"
assert thing(1, 2, 3) == "V1"
try:
thing(1, 2)
assert False
except TypeError:
assert True
Probably. There's some funky stuff around closures that may or may not work. Hard to tell right now.
Probably not.
There is a possibility for getting it to work in future, but it will probably double the size of the current code. I'll need to give it some thought.
Not even a little. It uses globals to do some dumb stuff, so we don't need to instance an object.
The power has been out for three hours, and it is 34C here. I was bored, and had an idea.
Simple, easy, and not requiring online documentation was sort of a must for occupying my brain in the heat.
Making use of this project is not a good idea at this stage.
However, see the LICENSE.md file.