-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
Per-subclass registries are nice, but an even nicer addition would be per-instance registries, e.g.
class C(SingleDispatch):
@singledispatch
def foo(self, bar): ...
c = C()
register(c.foo, some_type, some_function)
As an example use case, in mplcursors (https://mplcursors.readthedocs.io/en/stable/), I use functools.singledispatch to generate "cursor" implementation for various Matplotlib artist classes, but an end user cannot override the way a specific class is picked without modifying the global singledispatch object. Having per-instance registries would, well, allow such a per-instance override.
Metadata
Metadata
Assignees
Labels
No labels