| 400 | return lst |
| 401 | |
| 402 | def _dispatch(dispatch_args, *args, **kw): |
| 403 | types = tuple(type(arg) for arg in dispatch_args) |
| 404 | try: # fast path |
| 405 | f = typemap[types] |
| 406 | except KeyError: |
| 407 | pass |
| 408 | else: |
| 409 | return f(*args, **kw) |
| 410 | combinations = itertools.product(*ancestors(*types)) |
| 411 | next(combinations) # the first one has been already tried |
| 412 | for types_ in combinations: |
| 413 | f = typemap.get(types_) |
| 414 | if f is not None: |
| 415 | return f(*args, **kw) |
| 416 | |
| 417 | # else call the default implementation |
| 418 | return func(*args, **kw) |
| 419 | |
| 420 | return FunctionMaker.create( |
| 421 | func, 'return _f_(%s, %%(shortsignature)s)' % dispatch_str, |