Skip to main content

SciJIT (scijit)

📖 Documentation: https://shmuel-gilbaum.github.io/SciJit/

A scipy-equivalent library callable from inside numba @njit code. scijit either wraps the same Fortran packs scipy wraps, or re-implements scipy's pure-Python routines as @njit. Results match scipy, verified against it in the test suite. Where a routine differs from scipy, its Notes say so; an argument it does not implement raises rather than silently returning something else. It pays off most when the same routine runs many times inside a compiled loop, where scipy would pay Python's per-call overhead on every iteration. Same namespaces, same names, same grouping. Not every scipy subpackage is mirrored; see docs/roadmap.md for the gaps.

scijit is not affiliated with, or endorsed by, the NumPy, SciPy or Numba projects. It is also distinct from numba-scipy, which provides numba support for a small part of scipy.special.

The approach comes from NumbaMinpack (Nicholas Wogan): reach a compiled Fortran pack from @njit through a @cfunc address and a bind(c) wrapper. scijit applies it across many packs. See docs/credits.md.

scipy's classes are called like spl(x), but a numba jitclass has no __call__, so a compiled class cannot be called that way. To mirror scipy, scijit uses scijitclass, a companion package that adds __call__ to numba jitclasses, so scijit's classes keep scipy's call syntax inside @njit. It is a standalone @jitclass replacement, usable in any numba project.

Anything numba already handles is out of scope: the numpy features numba supports, and the scipy.special subset numba-scipy covers.

scijit was written mostly with Anthropic's Claude (via Claude Code) under my direction. I set the architecture and the design choices, and every routine is verified against SciPy in the test suite.

Subpackages

Three scipy subpackages, callable from inside @njit:

  • scijit.interpolate — splines and the interpolator classes (scipy.interpolate).
  • scijit.optimize — roots, least squares, and minimization (scipy.optimize).
  • scijit.integratequad, solve_ivp, odeint, and quadrature (scipy.integrate).

Each routine's coverage, backing Fortran, and scipy parity are in the usage guides and API reference. More subpackages (fft, linalg, stats, special, and others) are in development; see docs/roadmap.md.

Install

pip install scijit

The wheels bundle the compiled Fortran, so nothing extra is needed on that path. A source install compiles each Fortran pack and requires gfortran on the PATH. Full instructions and troubleshooting are in docs/install.md.

Example

Build an interpolant once, then use it inside compiled code:

import numpy as np
from numba import njit
from scijit.interpolate import CubicSpline
from scijit.integrate import simpson

# a coarse lookup table: opacity sampled at a few log-temperatures
logT   = np.array([3.0, 4.0, 5.0, 6.0, 7.0, 8.0])
logkap = np.array([0.1, 0.4, 1.2, 2.0, 1.5, 0.6])
opacity = CubicSpline(logT, logkap)        # build the interpolant once

@njit
def mean_opacity(opacity, T_lo, T_hi, n_cells=101):
    T = np.linspace(T_lo, T_hi, n_cells)
    return simpson(opacity(T), T) / (T_hi - T_lo)   # band-averaged, all in @njit

mean_opacity(opacity, 3.5, 7.5)            # -> 1.260677088

opacity(...) evaluates the spline, from Python and inside @njit, exactly as in scipy, and simpson integrates it in the same compiled function. Build the interpolant once and reuse it. A full walkthrough is in docs/getting_started.md.

Performance: when this helps

The gain comes from removing interpreter overhead, so it shows up in large or nested loops. scipy cannot be called from @njit, so it pays the interpreter on every iteration. Reproduce with python benchmarks/<name>.py:

benchmark workload speedup
bench_pde_front.py 1-D Burgers front (MOL + LSODA), a 2-var fsolve per gridpoint per adaptive step 20-30x
bench_ode_implicit.py 400 stiff ODEs, a 3-var fsolve inside every LSODA step 15-25x
speed_grid.py 18000-cell grid: root solve + opacity spline + simpson 10-20x

Speedups are approximate and vary with machine, problem size and thread count. Intel SVML has been unsupported by numba since 0.62, which costs some vectorized performance on both sides of these comparisons.

The speedup tracks how much of each iteration is interpreter overhead, since that is what the compiler removes. It is not a claim about the numerics: where scijit calls Fortran, the same Fortran runs in both cases. numba also compiles on first call, which can make a single isolated call slower.

Rule of thumb:

  • one large vectorized call from Python (bench_where_scipy_wins.py) → use scipy. The shipped subpackages wrap the same Fortran, so a single big call ties: a 200k-point bivariate spline evaluation matched scipy within 4%, with identical results (max|diff| 0).
  • a small solve repeated many times, or nested loops → use scijit.

Documentation

The full documentation site is at https://shmuel-gilbaum.github.io/SciJit/ (Markdown sources under docs/).

  • docs/getting_started.md: a first end-to-end @njit workflow.
  • docs/install.md: wheel install, source install, and the import-failure note.
  • docs/usage/index.md: task-by-task usage guides, one tested runnable example per function.
  • docs/compatibility.md: supported versions, where agreement with scipy is bit-for-bit and where it is not, thread safety, and the prange-safety matrix.
  • docs/architecture.md: what a call passes through, from the entry points down through the callback adapter, the ctypes boundary, the return types, and the jitclass rules.
  • docs/roadmap.md: what is not covered yet, and why.
  • docs/credits.md: provenance and the upstream library and license table.

How this project started

In 2021, during my PhD in astrophysics I was running an AGN accretion-disk simulation: a large coupled ODE system where every integration step had to solve 3 nonlinear equations at each of thousands of grid points. Both the root-solving and the variable extraction that followed depended on opacity tables, read through bivariate spline interpolation.

NumbaMinpack let me do the root-finding inside @njit code, but scipy's spline evaluators cannot be called there. So I followed NumbaMinpack's approach and wrapped the two FITPACK routines I needed for the table lookups, bispev and bispeu. The runtime dropped from unusable to a few hours.

scijit is the follow-up, built together with Claude: the whole of FITPACK instead of those two routines, then the other Fortran packs behind scipy, plus @njit versions of the routines scipy writes in Python.

License & citation

scijit wraps established numerical libraries; each subpackage carries its upstream license in src/<pack>/, and the full citation list is in CITATION.cff (GitHub "Cite this repository"). Credit details are in docs/credits.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scijit-0.1.1.tar.gz (5.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

scijit-0.1.1-py3-none-win_amd64.whl (7.3 MB view details)

Uploaded Python 3Windows x86-64

scijit-0.1.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

scijit-0.1.1-py3-none-macosx_14_0_arm64.whl (6.3 MB view details)

Uploaded Python 3macOS 14.0+ ARM64

File details

Details for the file scijit-0.1.1.tar.gz.

File metadata

  • Download URL: scijit-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scijit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ad6efe159286203b81b05d37c50f69af839bed4abce4a11437124ee11d007304
MD5 427f0d6ba5f0ef115a202962088c7e85
BLAKE2b-256 54ccca543875b61e40b1f9287f1e8f857abb120a04fd27795d26257b4b5a182d

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.1.tar.gz:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scijit-0.1.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: scijit-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 7.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for scijit-0.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1969cfc548805b80a2186904af03b1bdd71713ab27f5587bee97c71c3677f60a
MD5 b859b7b6ecc378702aa66a4f1e5a4f22
BLAKE2b-256 ecc84f307169aa77cc80f493f1748a6b749a1f64ff87ea724432795e9604a20c

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.1-py3-none-win_amd64.whl:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scijit-0.1.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for scijit-0.1.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7b651130fcef5ffb9ff5161c8b4c2e4960dbe4907b4c56a171510dc1bd21486c
MD5 263c45837a39337eeed322638ea3b624
BLAKE2b-256 e8444aaa7f7ad28c0c9d45adbb461b135671ce1a5b79b671aa6480f733e19864

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scijit-0.1.1-py3-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for scijit-0.1.1-py3-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 103aa8a70f531dc65d6424a6681993c4ebec41315daf2fd8f3155f5795b90cf2
MD5 0f50849bc833174fb3e01a9c2d12c99b
BLAKE2b-256 7ad0a0a5f6189f6fcad7a2fd2e3f208455ed99503da77ec53bffa744fbed6e48

See more details on using hashes here.

Provenance

The following attestation bundles were made for scijit-0.1.1-py3-none-macosx_14_0_arm64.whl:

Publisher: wheels.yml on Shmuel-Gilbaum/SciJit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

4 files

0.1.0

4 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page