hotkernels
Faster NumPy on Apple Silicon and on x86-64 Linux, with one line and no other change to your code.
import hotkernels
hotkernels.install()
install() points NumPy at hand-written assembly kernels, ARM64 NEON or x86-64 AVX2, for the calls where NumPy is slowest. Every kernel is checked against NumPy's own output, including NaN, infinities, signed zeros and ties, and is memory-safe by test. A call no kernel handles goes to NumPy exactly as it was written.
Install
pip install hotkernels
Wheels are for macOS on Apple Silicon and for Linux on x86-64 (glibc), CPython 3.11 to 3.14, with NumPy 2.3 or a later NumPy 2. Another Python on one of those builds from source, which needs the Xcode command line tools on a Mac, or a C compiler and GNU binutils on Linux. On Linux the processor must have the x86-64-v3 instruction sets (AVX2, FMA, BMI1, BMI2, LZCNT, MOVBE, POPCNT), which Intel processors have had since 2013 and AMD's since 2015; on an older one, and on any other machine, install() does nothing and report() says why, so code that calls it stays portable.
The speed figures on this page were measured on an Apple M1 Pro. On x86-64 NumPy has vector loops of its own for some of these calls, so the gains differ: larger for some, close to none for clip and astype.
What gets faster
np.argmax, np.argmin (also along the rows of a matrix: np.argmax(m, axis=1) on 300,000 rows of ten float64 is about 3.5x faster than NumPy on an Apple M1 Pro, and on rows of two or three about 15x), np.clip (on int64 for arrays of up to 4,096 elements), x[mask] (and np.compress, np.extract), x[mask] = v (and np.putmask, np.copyto(..., where=mask)), np.nonzero (and np.where(mask); on a two-dimensional boolean array in C order too, about 5x faster than NumPy for 40 rows of 22 with 5% True and 15x to 27x at a million elements on an Apple M1 Pro, 10x to 24x on an Intel Core i5-14600KF, and np.argwhere, which calls it), np.where(mask, a, b) on arrays of one shape, np.cumsum (on boolean masks too), np.maximum.accumulate and np.fmax.accumulate on one-dimensional arrays, accumulations down the columns of a float64 matrix (a.cumsum(axis=0), a.cumprod(axis=0), np.maximum.accumulate(a, axis=0), np.fmax.accumulate(a, axis=0); about 7x to 10x faster at 253 × 4,789 on an Apple M1 Pro), np.fmax.reduceat on short runs (runs of 16 are about 3x faster than NumPy at a million elements on an Apple M1 Pro; runs of 256 or more are slower than NumPy on large arrays, by up to 1.6x on Apple Silicon), m.any(axis=1) and m.any(axis=0) on two-dimensional boolean arrays, np.round on float64 arrays of up to 4,096 elements and on one float64 number (an np.float64 or a zero-dimensional array), np.median and np.median(x, axis=None) on float64, a stable np.argsort (kind="stable", kind="mergesort" or stable=True) on one-dimensional float64, int64 and uint64 arrays of 256 elements or more, w -= b and w += b on float64 arrays of 131,072 elements (1 MB) or more on Apple Silicon (faster only right after a large matrix product has read w on several cores, as in a training loop's gradient step; elsewhere NumPy's speed), x.astype(np.float32) from uint8, np.sum on uint8 and on boolean masks, np.sum(x) and x.sum() on one-dimensional float32 and float64 arrays (NumPy's result bit for bit: the same additions in NumPy's order, several of its blocks at a time; about 20x faster than NumPy on 16 elements and 3x on a million float32, 1.9x on a million float64, on an Apple M1 Pro, and on an Intel Core i5-14600KF about 24x and 2.6x on float32, 23x and 1.6x on float64; a sum that is not finite is left to NumPy), np.count_nonzero, np.histogram, np.bincount (on uint8, int16 and int64), np.unique on int64 labels (a range of values no wider than 256 or than the array; without counts, an inverse or indices), np.isin (on int64 and int32, with up to eight test values; on an Intel Core i5-14600KF about 20x faster than NumPy at a million int32), np.searchsorted on float64 with float64 or float32 needles and on int64 with int64 needles (and np.digitize, which calls it) and np.interp, for the element types each kernel covers. At a million elements, from Python, x[mask] on float32 is about 31x faster and np.histogram about 9x. x[mask] covers float32, float64, int32, int64, int16, uint16, uint8, int8 and bool (on an Intel Core i5-14600KF about 56x faster than NumPy at a million uint8 with half the mask True, 36x on int16), and x[mask] = v the first four when v is a plain number of the array's kind (a Python float for the floats, a Python int in range, or the array's own scalar type; any other value goes to NumPy, which converts it by its own rules): on an Intel Core i5-14600KF x[mask] = 0.0 on a million float32 with half the mask True is about 31x faster than NumPy. Elementwise operations on small arrays, a + b, a * 2.0, a > 0, np.exp(a), x += y and every other NumPy ufunc with one or two inputs, run NumPy's own loop without NumPy's call path, so the result is NumPy's bit for bit: on an Apple M1 Pro at 16 float64 elements a + b is about 2x faster than NumPy and a > 0 3x, for arrays of up to 16,384 elements of one shape, an array and a row of it, or an array and a number. On small arrays most of a NumPy call is NumPy's own call path, which hotkernels skips where it can: on 16 elements np.clip(x, -0.5, 0.5) is about 10x faster, when its bounds are plain numbers and there is no out other than x itself (np.clip(x, lo, hi, out=x) clips in place), and np.argmax(x) about 14x. np.clip on a short int64 array, and np.round and np.median on a short float64 one, which no kernel serves, are answered by plain C loops inside hotkernels for the same reason: np.median of 16 elements about 45x faster, measured on x86-64. On larger arrays np.median is a loop of hotkernels too, at every size, which finds the middle elements from the bits of the numbers instead of partitioning a copy: about 8x faster at a million float64 on an Apple M1 Pro, though about level with NumPy, whose partition is quick there, on data already in order. The accumulations down the columns of a matrix are plain C loops too, at every size: NumPy walks a column at a time, a row apart between elements, and hotkernels walks the rows.
Libraries such as pandas and empyrical send some NaN-aware reductions to bottleneck rather than NumPy. When bottleneck is installed, hotkernels also serves bottleneck.nanmean, nanstd, nanmin and nanmax along one axis of a two-dimensional float64 array whose kept axis is contiguous (axis=0 of a C-ordered array or of a rolling-window view), with bottleneck's result bit for bit, about 4x to 7x faster at 252 × 4,789. It never imports bottleneck; the functions are served from when it is imported.
Using it
import numpy as np
import hotkernels
hotkernels.install() # NumPy now uses the kernels, in the whole process
x = np.random.standard_normal(1_000_000)
x[x > 0] # served by a kernel
print(hotkernels.report()) # what is installed, and how often each kernel ran
hotkernels.uninstall() # NumPy is exactly as it was
hotkernels.install(inexact=True)also installsnp.cumsumonfloat32andfloat64, which are within a declared tolerance of NumPy rather than bit-identical.hotkernels.install(bottleneck=False)leaves bottleneck's functions alone.with hotkernels.enabled():installs for the duration of a block, and puts hotkernels back as it found it when the block ends; it takes the same arguments asinstall().
Without changing your code
python -m hotkernels my_script.py --its --own --arguments
python -m hotkernels -m pytest
python -m hotkernels --report my_script.py # print report() to standard error at the end
Documentation, the full results and how the kernels are made: sofeikov.github.io/hotkernels and github.com/sofeikov/hotkernels.
Metadata
Release files for hotkernels 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hotkernels-0.4.0.tar.gz | 348.7 kB | With provenance | Details for hotkernels-0.4.0.tar.gz |
Built distributions (wheels)
Total release size: 1.4 MB
Release files / hotkernels-0.4.0.tar.gz
| Download URL | hotkernels-0.4.0.tar.gz |
|---|---|
| Size | 348.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a5a6606276963bbbd01e7e11293a96043df1ea7e331c980d58c0d7e26850da8
|
|
BLAKE2b-256 checksum How to use checksums |
95a3e75512dad37fdfb71fb95455c2ad8e95559c9f95ab36555533ef35afa8eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | hotkernels-0.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 137.8 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
95967bd882d743e558972d1f0354caafe8d71e46d4cedcd9e54a7dbab0b86f5d
|
|
BLAKE2b-256 checksum How to use checksums |
5b5f0a2aac6e39686e119097010ced0af0417d0b2edaf9e9cccef3f222bcad22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | hotkernels-0.4.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 130.9 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
731759421c7e7b3cbd035b0006f51e2149d103c30ef075521bdc0d9c5ed80d34
|
|
BLAKE2b-256 checksum How to use checksums |
986c012a4e83b3e094930c3f3fae356c98e32060765f40eed3ca143895830d63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | hotkernels-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 137.7 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
f231916b8541456f7da56057b760e0c11ece42e8a97f8f47975c581ed562bd25
|
|
BLAKE2b-256 checksum How to use checksums |
75c0823b4e3fce65715b74612ca5673831c6688d8538b95b91880b900115893d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | hotkernels-0.4.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 130.8 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
29ba4b7d51b02acc0062d477378fab2d9d11e9c587db02375bdab032f657e913
|
|
BLAKE2b-256 checksum How to use checksums |
cf05aaf1b503cbc0983b356a92b4734e4e5cbd735c308cafa6a003e9313be0aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | hotkernels-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 137.8 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
d9aea8179093e20267eac80803658404feb6b3d8a4ef3523597e946244f5c727
|
|
BLAKE2b-256 checksum How to use checksums |
ee2d7ecc47ae15a170ba6a1c96a8c5fa637bd493ae5f7ef1b9daca6300b00657
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | hotkernels-0.4.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 130.8 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5560788bd63fc31bcd7c4cb5a9344f7b83ec4c12017531489d0b19a846f4d69a
|
|
BLAKE2b-256 checksum How to use checksums |
12cadf3dc52e9fa0c98418f6f98b99dbaa3f73a537dd61cd59897053ad074f28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | hotkernels-0.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 137.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b04b4d73de15e92358c5168a3a6bba24e386a1b0efa7eae88f343d19da72cd41
|
|
BLAKE2b-256 checksum How to use checksums |
8f73e952f1cccaa1d047918d46359868cd25af0bf89d45acb89173124db34478
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / hotkernels-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | hotkernels-0.4.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 130.6 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ff8c6d6d0d7abf6aa882b3730170ec39170184573082db8ff32948bc373ae8df
|
|
BLAKE2b-256 checksum How to use checksums |
43b9bf88568a602cd397774646fa5d5cf559ca1a489bacbdc9129a2d136cf941
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for hotkernels 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for hotkernels-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.