Ideally, the only thing an end-user should have to do is set the backend and its options. Given a backend, you (as the end-user) can decide to do one of two things:
Set the backend permanently (use the
Set the backend temporarily (use the
API authors may want to wrap these methods and provide their own methods.
Also of a note may be the
BackendNotImplementedError, which is raised
when none of the selected backends have an implementation for a multimethod.
Setting the backend temporarily¶
To set the backend temporarily, use the
set_backend context manager.
import uarray as ua with ua.set_backend(mybackend): # Use multimethods (or code dependent on them) here.
Setting the backend permanently¶
To set the backend permanently, use the
method. It is a recommendation that the global backend should not
depend on any other backend, as it is not guaranteed that another
backend will be available.
import uarray as ua ua.set_global_backend(mybackend) # Use relevant multimethods here.