SPEC 2 — API Dispatch

Authors:
Ivan Yashchuk <ivan.yashchuk@quansight.com>, Ralf Gommers <rgommers@quansight.com>, Jarrod Millman <millman@berkeley.edu>, Stéfan van der Walt <stefanv@berkeley.edu>
Discussion:
https://discuss.scientific-python.org/t/spec-2-api-dispatch/173
History:
https://github.com/scientific-python/specs/commits/main/spec-0002
Endorsed by:
Attention

This is a draft document.

Description#

We propose mechanisms for:

(a) wholesale reimplementations of library functions, and (b) function dispatch based on foreign data structures.

This would allow groups outside of, say, scipy to (a) provide new functions to replace parts of SciPy, or (b) provide data structures that can pass through SciPy’s existing computational pipelines.

Concretely, (a) is akin to monkey-patching, but with the advantage that libraries can coordinate dispatching and report which backend is being used. And (b) is similar to using the Array API standard, so that pure-Python algorithm implementations can operate on foreign array types without rewriting code.

This SPEC focuses on the rationale for these mechanisms, and provides links to implementations related technical discussions.

Notes#

On this page