Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (33 sloc) 1.52 KB
.. currentmodule:: uarray

End-user quickstart

Ideally, the only thing an end-user should have to do is set the backend and and its options. Given a backend, you (as the end-user) can decide to do one of two things:

Note

API authors may want to wrap these methods and provide their own methods.

Also of note may be the :obj:`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 :obj:`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 :obj:`set_global_backend` 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.

You can also register backends other than the global backend for permanent use, but the global backend will be tried first outside of a :obj:`set_backend` context. This can be done via :obj:`register_backend`.

import uarray as ua

ua.set_global_backend(mybackend)

# Use relevant multimethods here.
You can’t perform that action at this time.