Requirements and discussion of a type dispatcher for the ecosystem

Code says more than a thousand words and I got stuck on thinking about it yesterday. So here is a pretty full-featured prototype for what I was suggesting: GitHub - seberg/precodita: Rough prototype for a single-type but multiple-parameter type-dispatcher and user backend-selecter

The interesting stuff to look at will be to start with example.py which shows off how things work and what is supported.

To recap, two modes/features:

  1. strict type-dispatching. The better matching implementation is preferred. If two implementations have the same dispatch-type (promotables are currently ignored here), their priority is compared. Right now the newer defined backend (not registration) has priority.
  2. Enabling and prioritization: Some backends are opt-in. They are ignored by default, but enabled in a context. Within the context, their priority is set to higher than all others (only a nested with statement can get a higher priority)

Very briefly, like __array_function__ (or uarray), I do use the “relevant argument extractor” approach, limited only to a single kind of arguments.

Unsolved stuff includes things like pickling (not even sure what to expect here). I somewhat expect that thread/asyncio-safety is close to working right, but honestly, probably not quite right yet.