Skip to main content

PyLU

top language supported Python versions supported implementations CI status

version on PyPI PyPI package format dependency status

license open issues PRs welcome

Small nogil-compatible Cython-based solver for linear equation systems A x = b.

We use semantic versioning.

For my stance on AI contributions, see the collaboration guidelines.

Introduction

The algorithm is LU decomposition with partial pivoting (row swaps). The code requires only NumPy and Cython.

The main use case for PyLU (over numpy.linalg.solve) is solving many small systems inside a nogil block in Cython code, without requiring SciPy (for its cython_lapack module).

Python and Cython interfaces are provided. The API is designed to be as simple to use as possible.

The arrays are stored using the C memory layout.

A rudimentary banded solver is also provided, based on detecting the band structure (if any) from the initial full LU decomposition. For cases where L and U have small bandwidth, this makes the O(n**2) solve step run faster. The LU decomposition still costs O(n**3), so this is useful only if the system is small, and the same matrix is needed for a large number of different RHS vectors. (This can be the case e.g. in integration of ODE systems with a constant-in-time mass matrix.)

Examples

Basic usage:

import numpy as np
import pylu

A = np.random.random( (5,5) )
b = np.random.random( 5 )

x = pylu.solve( A, b )

For a complete tour, see the test suite.

The main item of interest, however, is the Cython API in dgesv.pxd. The main differences to the Python API are:

  • Function names end with _c.
  • Explicit sizes must be provided, since the arrays are accessed via raw pointers.
  • The result array x must be allocated by the caller, and passed in as an argument. See dgesv.pyx for examples on how to do this in NumPy.

Installation

From PyPI

pip install pylu

From source

git clone https://github.com/Technologicat/pylu.git
cd pylu
pip install .

For maximum performance on your machine, build with architecture-specific optimizations:

CFLAGS="-march=native" pip install --no-build-isolation .

Pre-built wheels from PyPI use generic -O2 because -march=native bakes in the instruction set of the build machine — a wheel built with AVX-512 would crash on a CPU without it. Building from source avoids this and lets the compiler target your specific hardware.

Development setup

PyLU uses meson-python as its build backend and PDM for dependency management.

git clone https://github.com/Technologicat/pylu.git
cd pylu
pdm install                              # creates venv, installs dev deps
pip install --no-build-isolation -e .    # editable install (needs venv activated)

The --no-build-isolation flag is required for editable installs with meson-python — the on-import rebuild mechanism needs build dependencies (Cython, NumPy, meson, ninja) to remain available in the environment, not just in a throwaway build-time overlay.

PATH note: The meson-python editable loader needs meson and ninja on PATH. If you get rebuild errors, ensure the venv's bin/ is on the path:

export PATH="$(pwd)/.venv/bin:$PATH"

Note on editable installs: After modifying .pyx or .pxd files, the next import auto-rebuilds the Cython extension — no manual reinstall step needed. For a clean non-editable build, use pip install . and reinstall after changes.

Dependencies

Requires Python ≥ 3.11.

License

BSD. Copyright 2016–2026 Juha Jeronen, University of Jyväskylä, and JAMK University of Applied Sciences.

Acknowledgement

This work was financially supported by the Jenny and Antti Wihuri Foundation.

Download files

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

Source Distribution

pylu-1.0.1.tar.gz (39.9 kB view details)

Uploaded Source

Built Distributions

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

pylu-1.0.1-cp314-cp314-win_amd64.whl (92.8 kB view details)

Uploaded CPython 3.14Windows x86-64

pylu-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (122.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pylu-1.0.1-cp314-cp314-macosx_11_0_arm64.whl (92.8 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pylu-1.0.1-cp313-cp313-win_amd64.whl (90.1 kB view details)

Uploaded CPython 3.13Windows x86-64

pylu-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (122.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pylu-1.0.1-cp313-cp313-macosx_11_0_arm64.whl (92.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pylu-1.0.1-cp312-cp312-win_amd64.whl (90.1 kB view details)

Uploaded CPython 3.12Windows x86-64

pylu-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (122.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pylu-1.0.1-cp312-cp312-macosx_11_0_arm64.whl (92.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pylu-1.0.1-cp311-cp311-win_amd64.whl (90.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pylu-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (126.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

pylu-1.0.1-cp311-cp311-macosx_11_0_arm64.whl (91.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file pylu-1.0.1.tar.gz.

File metadata

  • Download URL: pylu-1.0.1.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylu-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d3391bb5c1cf2c984d484b405f3ba3ea59384ccaf10cc97543a0c5a1b7321afc
MD5 cc0a9bd1485538a93ad7bc3ac3e6eefa
BLAKE2b-256 6350115bce733abab73e3b4a20bb0ca489854cfb814d9ea2ba7c36f7ac994088

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1.tar.gz:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pylu-1.0.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 92.8 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylu-1.0.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 53a36b41525461bda50483fc4149053fcdb996d3849f90cf8dc751093600abc2
MD5 69978917817df541a32dc8bacb7c68ad
BLAKE2b-256 1ca37d04bb634a0faf7a1de7a9b3b1278d25ddb7e97237f31ccbfc7a08551870

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp314-cp314-win_amd64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1cc061f0539d77969026f33f7225ef500cb10adfd7efa40f0188a7400d1f2b17
MD5 f2b43ac2663e77305bca07c30f1bf7fe
BLAKE2b-256 c822c744f93c58e4a153682490f96497d0831cc98a9e5a4bc721c9e9fa21404a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28cbbd4499ea6471ab4bc1a320dfdf9ea0b4266c31b9c50f0551ac5cefc754ee
MD5 1916fb743469d763350346a16272a8cc
BLAKE2b-256 93a82cfb73fc53af66d0401bfc2559f2a98968096c8656956870d6ee55cc15e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pylu-1.0.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 90.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylu-1.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 be518dfd8420482651124d6edc17f899eb855a1c2b2fd54d598fb6d8b1ccf263
MD5 142fa10d9d708478978083750b9622f5
BLAKE2b-256 ed631e1027f6ca73c1db973a2b2cf0a1c0a93b43d14f8b1cd5ff44eea6d31264

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp313-cp313-win_amd64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c46e3eebc05ae1199065ae5430d15cd3a36faa36dfdcaaae97b5935fa2129d1e
MD5 dc162bec5ffa4cd46e1969db73d5ad09
BLAKE2b-256 ffefe94fb5a1e7969954e44800f793144ce35672d25ff037b152dc9a637c5d86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09d2f9769c936732c381c11afec2e6cffc08af0ec304644d5ea647164673fb94
MD5 daa14df54769c194f4959abef7c00766
BLAKE2b-256 219e77d1dfc9da740eb4b2cc6b566ea23c24c708ddc94c64514ef307aa5f8527

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pylu-1.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 90.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylu-1.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b6e48e2f85e09f83a2c077115c208ed195dff9e954a220f3ccf117cac8f3575f
MD5 424424c8a176088cb2a66f49ec656913
BLAKE2b-256 7acdaa464be53c3a9694dbcdbb600e2254bd508a9c3b8af45211dc24b184f7e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp312-cp312-win_amd64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd7f29a36fa4810ea4af9de5b4a52d52819abe989fdaa30585157f4bc5a6f09b
MD5 948c4178ea0f4014a16d00b1d3558f6f
BLAKE2b-256 95f6e8dd0cca515c22aba2b7d01feb0d9c2efc40a20d449fa43baa2ff253ec87

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41da0c417faa38b6e417121a1289de7876bb6066c926e0015fdb4f6cfd96dcc6
MD5 5c83b41fe7e0e19d19742e2fd59e8ac4
BLAKE2b-256 67fbff8e9e7b9669de4fbc5111e1729c1c401293d04d384c015d237d6f575120

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pylu-1.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 90.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pylu-1.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fe9dd979ad95785edaf2cab6878f164f28c57a86d107d72d75d31c76d33d1bd4
MD5 39211edf01799752a3c9c1eebf853478
BLAKE2b-256 797c85ad73387fd48f19a4806f7ecc2136ef0b95255d959c17a3b01e6a52da10

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp311-cp311-win_amd64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d62e76b406e20e3262c0831c80e893d98d8ea7cc60f2abd0911c2b14e429611f
MD5 6c5ee9ae4a876b0c066e6845f6eaad79
BLAKE2b-256 fb3a5b696b10599c5ab0f136a418728f43daafa2df82af87a6cb9bf17f93f8ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on Technologicat/pylu

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

File details

Details for the file pylu-1.0.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pylu-1.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7f848b40fafeca934b272fe4dd29d8c0ea8cccdc0e4feafb360da3e8ec43f90
MD5 047824f61dcf5c65c7765d36de51e2ae
BLAKE2b-256 cf1150be59f8f70f282632cfc0034ee2f7fd0fb52c5776dfdbade5e1d94dd382

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylu-1.0.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci.yml on Technologicat/pylu

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

Release history Release notifications | RSS feed

1.1.0

16 files

This release

1.0.1 This release

13 files

1.0.0

13 files

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page