uarray
is a generic override framework for objects and methods in Python. Since my last uarray
blogpost, there have been plenty of developments, changes to the API and improvements to the overhead of the protocol. Let’s begin with a walk-through of the current feature set and API, and then move on to current developments and how it compares to __array_function__
. For further details on the API and latest developments, please see the API page for uarray
. The examples there are doctested, so they will always be current.
# Enable __array_function__ for NumPy < 1.17.0
!export NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=1
import uarray as ua
import numpy as np
In uarray
, the fundamental building block is a multimethod. Multimethods have a number of nice properties, such as automatic dispatch based on backends. It is important to note here that multimethods will be written by API authors, rather than implementors. Here's how we define a multimethod in uarray
:
Read more… (8 min remaining to read)
from Planet Python
via read more
No comments:
Post a Comment