Open
Description
In the example below, we have no real need to evaluate the type annotations of the non-dispatched args.
Skipping this might improve performance / import time a little.
While a little late for some nice features like X | Y
syntax, this is useful in case we introduce new typing syntax in the future, since it allows users to use it on non-dispatched args.
from __future__ import annotations
from functools import singledispatch
@singledispatch
def fun(arg, verbose):
print("arg", type(arg))
@fun.register
def _(arg: int, verbose: 1/0):
print("arg", type(arg))
@fun.register
def _(arg: list, verbose: 1/0):
print("arg", type(arg))