This is with Python 3.8.2 64-bit and numpy 1.19.2 on Windows 10. I'd
like to be able to convert some C++ extension type to a numpy array by
using ``numpy.asarray``. The extension type implements the Python
buffer interface to support this.
The extension type, called "Image" here, holds some chunk of
``double``, C order, contiguous, 2 dimensions. It "owns" the buffer;
the buffer is not shared with other objects. The following Python
image = <... Image production ...>
ar = numpy.asarray(image)
However, when I say::
image = <... Image production ...>
ar = numpy.asarray(image)
the entire program is executing properly with correct data in the
numpy ndarray produced using the buffer interface.
The extension type permits reading the pixel values by a method;
copying them over by a Python loop works fine. I am ``Py_INCREF``-ing
the producer in the C++ buffer view creation function properly. The
shapes and strides of the buffer view are ``delete``-ed upon
releasing the buffer; avoiding this does not prevent the crash. I am
catching ``std::exception`` in the view creation function; no such
exception occurs. The shapes and strides are allocated by ``new
Py_ssize_t``, so they will survive the view creation function.
I spent some hours trying to figure out what I am doing wrong. Maybe
someone has an idea about this? I double-checked each line of code
related to this problem and couldn't find any mistake. Probabaly I am
not looking at the right aspect.
Here is a NEP, written together with Stephan Hoyer and Aaron Meurer, for
discussion on adoption of the array API standard (
https://data-apis.github.io/array-api/latest/). This will add a new
numpy.array_api submodule containing that standardized API. The main
purpose of this API is to be able to write code that is portable to other
array/tensor libraries like CuPy, PyTorch, JAX, TensorFlow, Dask, and MXNet.
We expect this NEP to remain in draft state for quite a while, while we're
gaining experience with using it in downstream libraries, discuss adding it
to other array libraries, and finishing some of the loose ends (e.g.,
specifications for linear algebra functions that aren't merged yet, see
https://github.com/data-apis/array-api/pulls) in the API standard itself.
for an initial discussion about this topic.
Please keep high-level discussion here and detailed comments on
https://github.com/numpy/numpy/pull/18456. Also, you can access a rendered
version of the NEP from that PR (see PR description for how), which may be
We propose to adopt the `Python array API standard`_, developed by the
`Consortium for Python Data API Standards`_. Implementing this as a separate
new namespace in NumPy will allow authors of libraries which depend on NumPy
as well as end users to write code that is portable between NumPy and all
other array/tensor libraries that adopt this standard.
We expect that this NEP will remain in a draft state for quite a while.
Given the large scope we don't expect to propose it for acceptance any
time soon; instead, we want to solicit feedback on both the high-level
design and implementation, and learn what needs describing better in
NEP or changing in either the implementation or the array API standard
Motivation and Scope
Python users have a wealth of choice for libraries and frameworks for
numerical computing, data science, machine learning, and deep learning. New
frameworks pushing forward the state of the art in these fields are
every year. One unintended consequence of all this activity and creativity
has been fragmentation in multidimensional array (a.k.a. tensor) libraries -
which are the fundamental data structure for these fields. Choices include
NumPy, Tensorflow, PyTorch, Dask, JAX, CuPy, MXNet, and others.
The APIs of each of these libraries are largely similar, but with enough
differences that it’s quite difficult to write code that works with multiple
(or all) of these libraries. The array API standard aims to address that
issue, by specifying an API for the most common ways arrays are constructed
and used. The proposed API is quite similar to NumPy's API, and deviates
in places where (a) NumPy made design choices that are inherently not
to other implementations, and (b) where other libraries consistently
from NumPy on purpose because NumPy's design turned out to have issues or
For a longer discussion on the purpose of the array API standard we refer to
the `Purpose and Scope section of the array API standard <
and the two blog posts announcing the formation of the Consortium _ and
the release of the first draft version of the standard for community review
The scope of this NEP includes:
- Adopting the 2021 version of the array API standard
- Adding a separate namespace, tentatively named ``numpy.array_api``
- Changes needed/desired outside of the new namespace, for example new
methods on the ``ndarray`` object
- Implementation choices, and differences between functions in the new
namespace with those in the main ``numpy`` namespace
- A new array object conforming to the array API standard
- Maintenance effort and testing strategy
- Impact on NumPy's total exposed API surface and on other future and
under-discussion design choices
- Relation to existing and proposed NumPy array protocols
(``__array_ufunc__``, ``__array_function__``, ``__array_module__``).
- Required improvements to existing NumPy functionality
Out of scope for this NEP are:
- Changes in the array API standard itself. Those are likely to come up
during review of this NEP, but should be upstreamed as needed and this NEP
Usage and Impact
*This section will be fleshed out later, for now we refer to the use cases
in* `the array API standard Use Cases section <
In addition to those use cases, the new namespace contains functionality
is widely used and supported by many array libraries. As such, it is a good
set of functions to teach to newcomers to NumPy and recommend as "best
practice". That contrasts with NumPy's main namespace, which contains many
functions and objects that have been superceded or we consider mistakes -
that we can't remove because of backwards compatibility reasons.
The usage of the ``numpy.array_api`` namespace by downstream libraries is
intended to enable them to consume multiple kinds of arrays, *without having
to have a hard dependency on all of those array libraries*:
.. image:: _static/nep-0047-library-dependencies.png
Adoption in downstream libraries
The prototype implementation of the ``array_api`` namespace will be used
SciPy, scikit-learn and other libraries of interest that depend on NumPy, in
order to get more experience with the design and find out if any important
parts are missing.
The pattern to support multiple array libraries is intended to be something
def somefunc(x, y):
# Retrieves standard namespace. Raises if x and y have different
# namespaces. See Appendix for possible get_namespace
xp = get_namespace(x, y)
out = xp.mean(x, axis=0) + 2*xp.std(y, axis=0)
The ``get_namespace`` call is effectively the library author opting in to
using the standard API namespace, and thereby explicitly supporting
all conforming array libraries.
The ``asarray`` / ``asanyarray`` pattern
Many existing libraries use the same ``asarray`` (or ``asanyarray``) pattern
as NumPy itself does; accepting any object that can be coerced into a
We consider this design pattern problematic - keeping in mind the Zen of
Python, *"explicit is better than implicit"*, as well as the pattern being
historically problematic in the SciPy ecosystem for ``ndarray`` subclasses
and with over-eager object creation. All other array/tensor libraries are
more strict, and that works out fine in practice. We would advise authors of
new libraries to avoid the ``asarray`` pattern. Instead they should either
accept just NumPy arrays or, if they want to support multiple kinds of
arrays, check if the incoming array object supports the array API standard
by checking for ``__array_namespace__`` as shown in the example above.
Existing libraries can do such a check as well, and only call ``asarray`` if
the check fails. This is very similar to the ``__duckarray__`` idea in
Adoption in application code
The new namespace can be seen by end users as a cleaned up and slimmed down
version of NumPy's main namespace. Encouraging end users to use this
import numpy.array_api as xp
x = xp.linspace(0, 2*xp.pi, num=100)
y = xp.cos(x)
seems perfectly reasonable, and potentially beneficial - users get offered
one function for each purpose (the one we consider best-practice), and they
then write code that is more easily portable to other libraries.
No deprecations or removals of existing NumPy APIs or other backwards
incompatible changes are proposed.
The array API standard consists of approximately 120 objects, all of which
have a direct NumPy equivalent. This figure shows what is included at a
.. image:: _static/nep-0047-scope-of-array-API.png
The most important changes compared to what NumPy currently offers are:
- A new array object which:
- conforms to the casting rules and indexing behaviour specified by the
- does not have methods other than dunder methods,
- does not support the full range of NumPy indexing behaviour. Advanced
indexing with integers is not supported. Only boolean indexing
with a single (possibly multi-dimensional) boolean array is supported.
An indexing expression that selects a single element returns a 0-D
rather than a scalar.
- Functions in the ``array_api`` namespace:
- do not accept ``array_like`` inputs, only NumPy arrays and Python
- do not support ``__array_ufunc__`` and ``__array_function__``,
- use positional-only and keyword-only parameters in their signatures,
- have inline type annotations,
- may have minor changes to signatures and semantics of individual
functions compared to their equivalents already present in NumPy,
- only support dtype literals, not format strings or other ways of
- DLPack_ support will be added to NumPy,
- New syntax for "device support" will be added, through a ``.device``
attribute on the new array object, and ``device=`` keywords in array
functions in the ``array_api`` namespace,
- Casting rules that differ from those NumPy currently has. Output dtypes
be derived from input dtypes (i.e. no value-based casting), and 0-D arrays
are treated like >=1-D arrays.
- Not all dtypes NumPy has are part of the standard. Only boolean, signed
unsigned integers, and floating-point dtypes up to ``float64`` are
Complex dtypes are expected to be added in the next version of the
Extended precision, string, void, object and datetime dtypes, as well as
structured dtypes, are not included.
Improvements to existing NumPy functionality that are needed include:
- Add support for stacks of matrices to some functions in ``numpy.linalg``
that are currently missing such support.
- Add the ``keepdims`` keyword to ``np.argmin`` and ``np.argmax``.
- Add a "never copy" mode to ``np.asarray``.
Functions in the ``array_api`` namespace
Let's start with an example of a function implementation that shows the most
important differences with the equivalent function in the main namespace::
def max(x: array, /, *,
axis: Optional[Union[int, Tuple[int, ...]]] = None,
keepdims: bool = False
) -> array:
Array API compatible wrapper for :py:func:`np.max <numpy.max>`.
return np.max._implementation(x, axis=axis, keepdims=keepdims)
This function does not accept ``array_like`` inputs, only ``ndarray``. There
are multiple reasons for this. Other array libraries all work like this.
Letting the user do coercion of lists, generators, or other foreign objects
separately results in a cleaner design with less unexpected behaviour.
It's higher-performance - less overhead from ``asarray`` calls. Static
is easier. Subclasses will work as expected. And the slight increase in
because users have to explicitly coerce to ``ndarray`` on rare occasions
seems like a small price to pay.
This function does not support ``__array_ufunc__`` nor
These protocols serve a similar purpose as the array API standard module
but through a different mechanisms. Because only ``ndarray`` instances are
dispatching via one of these protocols isn't useful anymore.
This function uses positional-only parameters in its signature. This makes
more portable - writing ``max(x=x, ...)`` is no longer valid, hence if other
libraries call the first parameter ``input`` rather than ``x``, that is
The rationale for keyword-only parameters (not shown in the above example)
two-fold: clarity of end user code, and it being easier to extend the
in the future with keywords in the desired order.
This function has inline type annotations. Inline annotations are far
maintain than separate stub files. And because the types are simple, this
not result in a large amount of clutter with type aliases or unions like in
current stub files NumPy has.
DLPack support for zero-copy data interchange
The ability to convert one kind of array into another kind is valuable, and
indeed necessary when downstream libraries want to support multiple kinds of
arrays. This requires a well-specified data exchange protocol. NumPy already
supports two of these, namely the buffer protocol (i.e., PEP 3118), and
the ``__array_interface__`` (Python side) / ``__array_struct__`` (C side)
protocol. Both work similarly, letting the "producer" describe how the data
is laid out in memory so the "consumer" can construct its own kind of array
with a view on that data.
DLPack works in a very similar way. The main reasons to prefer DLPack over
the options already present in NumPy are:
1. DLPack is the only protocol with device support (e.g., GPUs using CUDA or
ROCm drivers, or OpenCL devices). NumPy is CPU-only, but other array
libraries are not. Having one protocol per device isn't tenable, hence
device support is a must.
2. Widespread support. DLPack has the widest adoption of all protocols, only
NumPy is missing support. And the experiences of other libraries with it
are positive. This contrasts with the protocols NumPy does support, which
are used very little - when other libraries want to interoperate with
NumPy, they typically use the (more limited, and NumPy-specific)
Adding support for DLPack to NumPy entails:
- Adding a ``ndarray.__dlpack__`` method
- Adding a ``from_dlpack`` function, which takes as input an object
supporting ``__dlpack__``, and returns an ``ndarray``.
DLPack is currently a ~200 LoC header, and is meant to be included
no external dependency is needed. Implementation should be straightforward.
Syntax for device support
NumPy itself is CPU-only, so it clearly doesn't have a need for device
However, other libraries (e.g. TensorFlow, PyTorch, JAX, MXNet) support
multiple types of devices: CPU, GPU, TPU, and more exotic hardware.
To write portable code on systems with multiple devices, it's often
to create new arrays on the same device as some other array, or check that
two arrays live on the same device. Hence syntax for that is needed.
The array object will have a ``.device`` attribute which enables comparing
devices of different arrays (they only should compare equal if both arrays
from the same library and it's the same hardware device). Furthermore,
``device=`` keywords in array creation functions are needed. For example::
def empty(shape: Union[int, Tuple[int, ...]], /, *,
dtype: Optional[dtype] = None,
device: Optional[device] = None) -> array:
Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.
return np.empty(shape, dtype=dtype, device=device)
The implementation for NumPy may be as simple as setting the device
the string ``'cpu'`` and raising an exception if array creation functions
encounter any other value.
Dtypes and casting rules
The supported dtypes in this namespace are boolean, 8/16/32/64-bit signed
unsigned integer, and 32/64-bit floating-point dtypes. These will be added
the namespace as dtype literals with the expected names (e.g., ``bool``,
The most obvious omissions are the complex dtypes. The rationale for the
of complex support in the first version of the array API standard is that
libraries (PyTorch, MXNet) are still in the process of adding support for
complex dtypes. The next version of the standard is expected to include
and ``complex128`` (see `this issue <
for more details).
Specifying dtypes to functions, e.g. via the ``dtype=`` keyword, is expected
to only use the dtype literals. Format strings, Python builtin dtypes, or
string representations of the dtype literals are not accepted - this will
improve readability and portability of code at little cost.
Casting rules are only defined between different dtypes of the same kind.
rationale for this is that mixed-kind (e.g., integer to floating-point)
casting behavior differs between libraries. NumPy's mixed-kind casting
behavior doesn't need to be changed or restricted, it only needs to be
documented that if users use mixed-kind casting, their code may not be
.. image:: _static/nep-0047-casting-rules-lattice.png
*Type promotion diagram. Promotion between any two types is given by their
join on this lattice. Only the types of participating arrays matter, not
their values. Dashed lines indicate that behaviour for Python scalars is
undefined on overflow. Boolean, integer and floating-point dtypes are not
connected, indicating mixed-kind promotion is undefined.*
The most important difference between the casting rules in NumPy and in the
array API standard is how scalars and 0-dimensional arrays are handled. In
the standard, array scalars do not exist and 0-dimensional arrays follow the
same casting rules as higher-dimensional arrays.
See the `Type Promotion Rules section of the array API standard <
for more details.
It is not clear what the best way is to support the different casting
for 0-dimensional arrays and no value-based casting. One option may be
implement this second set of casting rules, keep them private, mark the
array API functions with a private attribute that says they adhere to
these different rules, and let the casting machinery check whether for
This needs discussion.
An indexing expression that would return a scalar with ``ndarray``, e.g.
``arr_2d[0, 0]``, will return a 0-D array with the new array object. There
several reasons for that: array scalars are largely considered a design
which no other array library copied; it works better for non-CPU libraries
(typically arrays can live on the device, scalars live on the host); and
simply a consistent design. To get a Python scalar out of a 0-D array, one
simply use the builtin for the type, e.g. ``float(arr_0d)``.
The other `indexing modes in the standard <
do work largely the same as they do for ``numpy.ndarray``. One noteworthy
difference is that clipping in slice indexing (e.g., ``a[:n]`` where ``n``
larger than the size of the first axis) is unspecified behaviour, because
that kind of check can be expensive on accelerators.
The lack of advanced indexing, and boolean indexing being limited to a
n-D boolean array, is due to those indexing modes not being suitable for all
types of arrays or JIT compilation. Their absence does not seem to be
problematic; if a user or library author wants to use them, they can do so
through zero-copy conversion to ``numpy.ndarray``. This will signal
to whomever reads the code that it is then NumPy-specific rather than
to all conforming array types.
The array object
The array object in the standard does not have methods other than dunder
methods. The rationale for that is that not all array libraries have methods
on their array object (e.g., TensorFlow does not). It also provides only a
single way of doing something, rather than have functions and methods that
are effectively duplicate.
Mixing operations that may produce views (e.g., indexing, ``nonzero``)
in combination with mutation (e.g., item or slice assignment) is
`explicitly documented in the standard to not be supported <
This cannot easily be prohibited in the array object itself; instead this
be guidance to the user via documentation.
The standard current does not prescribe a name for the array object itself.
We propose to simply name it ``ndarray``. This is the most obvious name, and
because of the separate namespace should not clash with ``numpy.ndarray``.
This section needs a lot more detail, which will gradually be added when
the implementation progresses.
A prototype of the ``array_api`` namespace can be found in
The docstring in its ``__init__.py`` has notes on completeness of the
implementation. The code for the wrapper functions also contains ``# Note:``
comments everywhere there is a difference with the NumPy API.
Two important parts that are not implemented yet are the new array object
DLPack support. Functions may need changes to ensure the changed casting
The array object
Regarding the array object implementation, we plan to start with a regular
Python class that wraps a ``numpy.ndarray`` instance. Attributes and methods
can forward to that wrapped instance, applying input validation and
implementing changed behaviour as needed.
The casting rules are probably the most challenging part. The in-progress
dtype system refactor (NEPs 40-43) should make implementing the correct
behaviour easier - it is already moving away from value-based casting for
The dtype objects
We must be able to compare dtypes for equality, and expressions like these
The above implies it would be nice to have ``np.array_api.float32 ==
Dtypes should not be assumed to have a class hierarchy by users, however we
free to implement it with a class hierarchy if that's convenient. We
the following options to implement dtype objects:
1. Alias dtypes to those in the main namespace. E.g.,
2. Make the dtypes instances of ``np.dtype``. E.g., ``np.array_api.float32 =
3. Create new singleton classes with only the required methods/attributes
(currently just ``__eq__``).
It seems like (2) would be easiest from the perspective of interacting with
functions outside the main namespace. And (3) would adhere best to the
TBD: the standard does not yet have a good way to inspect properties of a
dtype, to ask questions like "is this an integer dtype?". Perhaps this is
enough to do for users, like so::
return dt_or_arr.dtype if hasattr(dt_or_arr, 'dtype') else dt_or_arr
dtype = _get_dtype(dtype_or_array)
return dtype in (float32, float64)
dtype = _get_dtype(dtype_or_array)
return dtype in (uint8, uint16, uint32, uint64, int8, int16, int32,
However it could make sense to add to the standard. Note that NumPy itself
currently does not have a great for asking such questions, see
We are developing a code that heavily relies on NumPy. Some of our regression tests rely on floating point number comparisons and we are a bit lost in determining how to choose atol and rtol (we are trying to do all operations in double precision). We would like to set atol and rtol as low as possible but still have the tests pass if we run on different architectures or introduce some ‘cosmetic’ changes like using different similar NumPy routines.
For example, let’s say we want some powers of the matrix A and compute them as:
A = np.array(some_array)
A2 = np.dot(A, A)
A3 = np.dot(A2, A)
A4 = np.dot(A3, A)
If we alternatively computed A4 like:
A4 = np.linalg.matrix_power(A, 4),
we get different values in our final outputs because obviously the operations are not equivalent up to machine accuracy.
Is there any reference that one could share providing guidelines on how to choose reasonable values for atol and rtol in this kind of situation? For example, does the NumPy package use a fixed set of values for its own development? the default ones?
Thanks in advance for any help,
I have code that performs dot product of a 2D matrix of size (on the
order of) [1000,16] with a vector of size . The matrix is
float64 and the vector is complex128. I was using numpy.dot but it
turned out to be a bottleneck.
So I coded dot2x1 in c++ (using xtensor-python just for the
interface). No fancy simd was used, unless g++ did it on it's own.
On a simple benchmark using timeit I find my hand-coded routine is on
the order of 1000x faster than numpy? Here is the test code:
My custom c++ code is dot2x1. I'm not copying it here because it has
some dependencies. Any idea what is going on?
import numpy as np
from dot2x1 import dot2x1
a = np.ones ((1000,16))
b = np.array([ 0.80311816+0.80311816j, 0.80311816-0.80311816j,
d = dot2x1 (a, b)
d = np.dot (a, b)
from timeit import timeit
print (timeit ('F1()', globals=globals(), number=1000))
print (timeit ('F2()', globals=globals(), number=1000))
In : 0.013910860987380147 << 1st timeit
28.608758996007964 << 2nd timeit
Those who don't understand recursion are doomed to repeat it
Our bi-weekly triage-focused NumPy development meeting is Wednesday,
Feb 24th at 11 am Pacific Time (19:00 UTC).
Everyone is invited to join in and edit the work-in-progress meeting
topics and notes:
I encourage everyone to notify us of issues or PRs that you feel should
be prioritized, discussed, or reviewed.
Thanks for asking, this is a simple explanation for your questions:
1. The download link of KML_BLAS:
The Chinese page is
The English page is https://kunpeng.huawei.com/en/#/developer/devkit/library,
you can find a "Math Library" Navigation entry in the bottom of this page.
"KML_BLAS" lies in there.
2. The license/redistribution policy of KML_BLAS:
The license is very similar to intel MKL, The license file is in the
process of making.
3.How to support KML_BLAS:
The support process is similar to BLIS, just need to add to
numpy.distutils, KML_BLAS will not open source in the near future.
4.What kind of ARM chips are supported:
any ARMV8 chip is supported.
Here is a NEP with guidelines around spending NumPy project funds for your
consideration/review, drafted by Inessa, Stéfan and myself. Please keep
discussion of the main ideas on this thread, and detailed/textual comments
We did quite a bit of research on relevant policies and practices in other
open source projects/communities. While we could find examples of
practices, we did not find any published policies like this. If you know of
any that are relevant, it'd be great if you could point to them.
:Author: Ralf Gommers <ralf.gommers(a)gmail.com>
:Author: Inessa Pawson <inessa(a)albuscode.org>
:Author: Stefan van der Walt <stefanv(a)berkeley.edu>
The NumPy project has historically never received significant
funding. However, that is starting to change. This NEP aims to provide
guidance about spending NumPy project unrestricted funds, by formulating a
of principles about *what* to pay for and *who* to pay. It will also touch
how decisions regarding spending funds get made, how funds get administered,
and transparency around these topics.
Motivation and Scope
In its 16+ year history, the NumPy project has only spent on the order of
$10,000 USD of funds that were not restricted to a particular program.
income of this type has been relying on donations from individuals and, from
May 2019, recurring monthly contributions from Tidelift. By the end of 2020,
the Tidelift contributions increased to $3,000/month, and there's also a
potential for an increase of donations and grants going directly to the
project. Having a clear set of principles around how to use these funds will
facilitate spending them fairly and effectively. Additionally, it will make
easier to solicit donations and other contributions.
A key assumption this NEP makes is that NumPy remains a largely
volunteer-driven project, and that the project funds are not enough to
maintainers full-time. If funding increases to the point where that
is no longer true, this NEP should be updated.
In scope for this NEP are:
- Principles of spending project funds: what to pay for, and who to pay.
- Describing how NumPy's funds get administered.
- Describing how decisions to spend funds get proposed and made.
Out of scope for this NEP are:
- Making any decisions about spending project funds on a specific project or
- Principles for spending funds that are intended for NumPy development, but
don't fall in the category of NumPy unrestricted funds. This includes
the grant funding, which is usually earmarked for certain
activities/deliverables and goes to an Institutional Partner rather than
directly to the NumPy project, and companies or institutions funding
*Rationale: As a project, we have no direct control over how this work
executed. In some cases, we may not even know the contributions were
or done by an employee on work time. (Whether that's the case or not
not change how we approach a contribution). For grants though, we do
the PI and funded team to align their work with the project's needs and be
receptive to feedback from other NumPy maintainers and contributors.*
Principles of spending project funds
NumPy will likely always be a project with many times more volunteer
contributors than funded people. Therefore having those funded people
in ways that attract more volunteers and enhance their participation
is critical. That key principle motivates many of the more detailed
given below for what to pay for and whom to pay.
What to pay for
1. Pay for things that are important *and* otherwise won't get done.
*Rationale: there is way more to be done than there are funds to do all
those things. So count on interested volunteers or external sponsored
to do many of those things.*
2. Plan for sustainability. Don't rely on money always being there.
3. Consider potential positive benefits for NumPy maintainers and
maintainers of other projects, end users, and other stakeholders like
packagers and educators.
4. Think broadly. There's more to a project than code: websites,
community building, governance - it's all important.
5. For proposed funded work, include paid time for others to review your
if such review is expected to be significant effort - do not just
the load on volunteer maintainers.
*Rationale: we want the effect of spending funds to be positive for
everyone, not just for the people getting paid. This is also a matter of
When considering development work, principle (1) implies that priority
be giving to (a) the most boring/painful tasks that no one likes doing, and
necessary structural changes to the code base that are too large to be done
a volunteer in a reasonable amount of time.
There are also a large amount of tasks, activities, and projects outside of
development work that are important and could enhance the project or
- think for example of user surveys, translations, outreach, dedicated
mentoring of newcomers, community organization, website improvements, and
Time of people to perform tasks is also not the only thing that funds can be
used for: expenses for in-person developer meetings or sprints, hosted
for benchmarking or development work, and CI or other software services
all be good candidates to spend funds on.
Whom to pay
1. All else being equal, give preference to existing
2. Consider this an opportunity to make the project more diverse.
3. Pay attention to the following when considering paying someone:
- the necessary technical or domain-specific skills to execute the tasks,
- communication and self-management skills,
- experience contributing to and working with open source projects.
It will likely depend on the project/tasks whether there's already a clear
candidate within the NumPy team, or whether we look for new people to get
involved. Before making any decisions, the decision makers should think
whether an opportunity should be advertised to give a wider group of people
chance to throw their hat in the ring for it.
Paying people fairly is a difficult topic. Therefore, we will only offer
guidance here. Final decisions will always have to be considered and
by the group of people that bears this responsibility (according to the
current NumPy governance structure, this would be the NumPy Steering
Discussions on employee compensation tend to be dominated by two narratives:
"pay local market rates" and "same work -- same pay".
We consider them both extreme:
- "Same work -- same pay" is unfair to people living in locations with a
cost of living. For example, the average rent for a single family
can differ by a large factor (from a few hundred dollar to thousands of
dollars per month).
- "Pay local market rates" bakes in existing inequalities between countries
and makes fixed-cost items like a development machine or a holiday trip
abroad relatively harder to afford in locations where market rates are
We seek to find a middle ground between these two extremes.
Useful points of reference include companies like GitLab and
Buffer who are transparent about their remuneration policies (_, _),
Google Summer of Code stipends (_), other open source projects that
their budget in a transparent manner (e.g., Babel and Webpack on Open
Collective (_, _)), and standard salary comparison sites.
Since NumPy is a not-for-profit project, we also looked to the nonprofit
for guidelines on remuneration policies and compensation levels. Our
show that most smaller non-profits tend to pay a median salary/wage. We
recognize merit in this approach: applying candidates are likely to have a
genuine interest in open source, rather than to be motivated purely by
Considering all of the above, we will use the following guidelines for
1. Aim to compensate people appropriately, up to a level that's expected for
senior engineers or other professionals as applicable.
2. Establish a compensation cap of $125,000 USD that cannot be exceeded even
for the residents from the most expensive/competitive locations
3. For equivalent work and seniority, a pay differential between locations
should never be more than 2x.
For example, if we pay $110,000 USD to a senior-level developer from New
York, for equivalent work a senior-level developer from South-East Asia
should be paid at least $55,000 USD. To compare locations, we will use
`Numbeo Cost of Living calculator <https://www.numbeo.com/cost-of-living/
(or its equivalent).
Some other considerations:
- Often, compensated work is offered for a limited amount of hours or fixed
term. In those cases, consider compensation equivalent to a remuneration
package that comes with permanent employment (e.g., one month of work
be compensated by at most 1/12th of a full-year salary + benefits).
- When comparing rates, an individual contractor should typically make 20%
than someone who is employed since they have to take care of their
and accounting on their own.
- Some people may be happy with one-off payments towards a particular
deliverable (e.g., hiring a cleaner or some other service to use the saved
time for work on open source). This should be compensated at a lower rate
compared to an individual contractor.
- When funding someone's time through their employer, that employer may
set the compensation level based on its internal rules (e.g., overhead
Small deviations from the guidelines in this NEP may be needed in such
however they should be within reason.
- It's entirely possible that another strategy rather than paying people for
their time on certain tasks may turn out to be more effective. Anything
helps the project and community grow and improve is worth considering.
- Transparency helps. If everyone involved is comfortable sharing their
compensation levels with the rest of the team (or better make it public),
it's least likely to be way off the mark for fairness.
We highly recommend that the individuals involved in decision-making about
hiring and compensation peruse the content of the References section of this
NEP. It offers a lot of helpful advice on this topic.
Defining fundable activities and projects
We'd like to have a broader set of fundable ideas that we will prioritize
input from NumPy team members and the wider community. All ideas will be
documented on a single wiki page. Anyone may propose an idea. Only members
NumPy team may edit the wiki page.
Each listed idea must meet the following requirements:
1. It must be clearly scoped: its description must explain the importance to
the project, referencing the NumPy Roadmap if possible, the items to pay
or activities and deliverables, and why it should be a funded activity.
2. It must contain the following metadata: title, cost, time duration or
estimate, and (if known) names of the team member(s) to execute or
3. It must have an assigned priority (low, medium, or high). This discussion
can originate at a NumPy community meeting or on the mailing list.
it must be finalized on the mailing list allowing everyone to weigh in.
If a proposed idea has been assigned a high priority level, a decision on
allocating funding for it will be made on the private NumPy Steering Council
mailing list. *Rationale: these will often involve decisions about
which is typically hard to do in public. This is the current practice that
seems to be working well.*
Sometimes, it may be practical to make a single funding decision ad-hoc
"Here's a great opportunity plus the right person to execute it right now”).
However, this approach to decision-making should be used rarely.
Strategy for spending/saving funds
There is an expectation from NumPy individual, corporate, and institutional
donors that the funds will be used for the benefit of the project and the
community. Therefore, we should spend available funds, thoughtfully,
strategically, and fairly, as they come in. For emergencies, we should keep
$10,000 - $15,000 USD reserve which could cover, for example, a year of CI
hosting services, 1-2 months of full-time maintenance work, or contracting a
consultant for a specific need.
How project funds get administered
We will first summarize how administering of funds works today, and then
discuss how to make this process more efficient and transparent.
Currently, the project funds are held by NumFOCUS in a dedicated account.
NumFOCUS has a small accounting team, which produces an account overview as
set of spreadsheets on a monthly basis. These land in a shared drive,
with about a one month delay (e.g., the balance and transactions for
are available at the end of March), where a few NumPy team members can
them. Expense claims and invoices are submitted through the NumFOCUS
Those then show up in another spreadsheet, where a NumPy team member must
review and approve each of them before payments are made. Following NumPy
bylaws, the NumFOCUS finance subcommittee, consisting of five people, meets
every six months to review all the project related transactions. (In
there have been so few transactions that we skipped some of these meetings.)
The existing process is time-consuming and error-prone. More transparency
automation are desirable.
Transparency about project funds and in decision making
**To discuss: do we want full transparency by publishing our accounts,
transparency to everyone on a NumPy team, or some other level?**
Ralf: I'd personally like it to be fully transparent, like through Open
Collective, so the whole community can see current balance, income and
paid out at any moment in time. Moving to Open Collective is nontrivial,
however we can publish the data elsewhere for now if we'd want to.
*Note: Google Season of Docs this year requires having an Open Collective
account, so this is likely to happen soon enough.*
Stefan/Inessa: at least a summary overview should be fully public, and all
transactions should be visible to the Steering Council. Full transparency of
all transactions is probably fine, but not necessary.
*The options here may be determined by the accounting system and amount of
History and current status
The NumPy project received its first major funding in 2017. For an overview
the early history of NumPy (and SciPy), including some institutions
time for their employees or contractors to work on NumPy, see _ and
date, NumPy has received four grants:
- Two grants, from the Alfred P. Sloan Foundation and the Gordon and Betty
Moore Foundation respectively, of about $1.3M combined to the Berkeley
Institute of Data Science. Work performed during the period 2017-2020;
PI Stéfan van der Walt.
- Two grants from the Chan Zuckerberg Foundation to NumFOCUS, for a combined
amount of $335k. Work performed during the period 2020-2021; PI's Ralf
Gommers (first grant) and Melissa Mendonça (second grant).
>From 2012 onwards NumPy has been a fiscally sponsored project of NumFOCUS.
Note that fiscal sponsorship doesn't mean NumPy gets funding, rather that it
can receive funds under the umbrella of a nonprofit. See `NumFOCUS Project
Support <https://numfocus.org/projects-overview>`__ for more details.
Only since 2017 has the NumPy website displayed a "Donate" button, and since
2019 the NumPy repositories have had the GitHub Sponsors button. Before
it was possible to donate to NumPy on the NumFOCUS website. The sum total of
donations from individuals to NumPy for 2017-2020 was about $6,100.
>From May 2019 onwards, Tidelift has supported NumPy financially as part of
its "managed open source" business model. From May 2019 till July 2020 this
$1,000/month, and it started steadily growing after that to about
(as of Feb 2021).
Finally there have been other incidental project income, for example some
royalties from Packt Publishing, GSoC mentoring fees from Google, and
merchandise sales revenue through the NumFOCUS web shop. All of these were
small (two or three figure) amounts.
This brings the total amount of project income which did not already have a
spending target to about $35,000. Most of that is recent, from Tidelift.
Over the past 1.5 years we spent about $10,000 for work on the new NumPy
website and Sphinx theme. Those spending decisions were made by the NumPy
Steering Council and announced on the mailing list.
That leaves about $25,000 in available funds at the time of writing, and
that amount is current growing at a rate of about $3,000/month.
See references. We assume that there are other open source projects having
published guidelines on spending project funds, however we don't have
examples at this time.
*Alternative spending strategy*: not having cash reserves. The rationale
being that NumPy is important enough that in a real emergency some person or
entity will likely jump in to help out. This is not a responsible approach
financial stewardship of the project though. Hence, we decided against it.
References and Footnotes
..  Pauli Virtanen et al., "SciPy 1.0: fundamental algorithms for
computing in Python",
..  Charles Harris et al., "Array programming with NumPy",
..  https://remote.com/blog/remote-compensation
..  https://developers.google.com/open-source/gsoc/help/student-stipends
..  Jurgen Appelo, "Compensation: what is fair?",
..  Project Include, "Compensating fairly",
.. [#f-pay] This cap is derived from comparing with compensation levels at
other open source projects (e.g., Babel, Webpack, Drupal - all
the $100,000 -- $125,000 range) and Partner Institutions.
- Nadia Eghbal, "Roads and Bridges: The Unseen Labor Behind Our Digital
- Nadia Eghbal, "Working in Public: The Making and Maintenance of Open
- Daniel Oberhaus, `"The Internet Was Built on the Free Labor of Open Source
Developers. Is That Sustainable?"
- David Heinemeier Hansson, `"The perils of mixing open source and money" <
- Danny Crichton, `"Open source sustainability" <
- Nadia Eghbal, "Rebuilding the Cathedral",
- Nadia Eghbal, "Where money meets open source",
- Eileen Uchitelle, ""The unbearable vulnerability of open source",
https://www.youtube.com/watch?v=VdwO3LQ56oM, 2017 (the inverted triangle,
open source is a funnel)
- Dries Buytaert, "Balancing Makers and Takers to scale and sustain Open
- Safia Abdalla, "Beyond Maintenance",
- Xavier Damman, "Money and Open Source Communities",
- Aseem Sood, "Let's talk about money",
- Alanna Irving, "Has your open source community raised money? Here's how
to spend it.",
- Alanna Irving, "Funding open source, how Webpack reached $400k+/year",
- Alanna Irving, "Babel's rise to financial sustainability",
- Devon Zuegel, "The city guide to open source",
https://www.youtube.com/watch?v=80KTVu6GGSE, 2020 + blog:
- https://blog.opencollective.com/on-github-sponsors/, 2019
- https://blog.opencollective.com/double-the-love/, 2020
Whether you're running apps on your phone or the world's fastest
supercomputer, you're most likely running ARM. Many major events have
occurred related to ARM archtecture:
- Apple may have done the most to make ARM relatively relevant in
popular culture with its new ARM-based M1 processor.
- Amazon Web Services launched its Graviton2 processors based on the Arm
architecture , which promise up to 40% better performance from comparable
x86-based instances for 20% less.
- Microsoft currently uses Arm-based chips from Qualcomm in some of its
- Huawei unveiled a new chipset called the Kunpeng based on ARM,
designed to go into its new TaiShan servers, in a bid to boost its nascent
So It's obvious that ARM will become more and more popular in the
future, Since Intel MKL has provide good accelerate support for X86-based
chips, Huawei also published KML_BLAS
library blas) that can make full advantage of ARM-based chips, KML_BLAS is
a mathematical library for basic linear algebra operations. it provides
three levels of high-performance vector operations: vector-vector
operations, vector-matrix operations, and matrix-matrix operations. The
performance advantage is shown in the attachment compared with OpenBlas.
Can we add KML_BLAS support to numpy?
Chunlin Fang(github ID:Qiyu8)