skillfed

cypari2

A Python interface to the number theory library PARI/GP

cypari2 v2.2.4 126.2K downloads/30d#11,787 on PyPI32
Copyleft license GPL-2.0-or-later Active released

What it is and what it does

cypari2 is a Python wrapper around PARI/GP, a mature C library for computational number theory. It exposes PARI's functions as methods on Python objects, allowing you to perform operations like polynomial factorization, zeta function evaluation, and finite field arithmetic from Python code. The interface mirrors PARI/GP's syntax closely—you can pass Python integers, floats, or PARI expression strings to the Pari() constructor and call methods directly on the resulting objects.

The package depends on cysignals for signal handling and requires a C compiler and PARI/GP headers to build from source, though pre-built wheels are available for Python 3.12+ on Linux, macOS, and musllinux. It is actively maintained by the SageMath community and carries a GPL-2.0-or-later license, which restricts use in proprietary software unless you comply with GPL terms or obtain a separate license.

Use it for:

  • Compute number-theoretic functions like zeta, factorization, and elliptic curve operations in Python scripts.
  • Factor polynomials over finite fields and perform algebraic number theory computations.
  • Prototype mathematical algorithms that will later be implemented in compiled code.
  • Integrate PARI/GP computations into larger Python scientific or educational applications.
  • Perform modular arithmetic and finite field operations for cryptographic research.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

cypari2 provides a Python interface to PARI/GP, a number theory library, exposing PARI functions as Python methods on wrapped objects.

Yes, if you need computational number theory in Python and accept GPL-2.0-or-later licensing. The package is actively maintained, has no known vulnerabilities, and offers pre-built wheels for modern Python versions, reducing install friction. Not suitable for proprietary software without GPL compliance or a separate license. Verify that pre-built wheels include the specific PARI/GP features you need before committing to this dependency.

Install

cypari2 on PyPI

pip

pip install cypari2

uv

uv add cypari2

poetry

poetry add cypari2

Installing cypari2

Before you install

Medium install friction due to compiled C extension and runtime dependency on cysignals. Pre-built wheels available for modern Python (3.12+) on common platforms reduce friction; building from source requires PARI/GP headers, GMP, C compiler, and pkg-config. Package is actively maintained by the SageMath community with recent commits.

License in practice

Licensed under GPL-2.0-or-later (copyleft). Use in proprietary software requires either GPL compliance or a separate commercial license; derivative works must be distributed under compatible terms.

Quickstart

pip install cypari2

import cypari2
pari = cypari2.Pari()
result = pari(2).zeta()
print(result)

Requires Python >= 3.12. Pre-built wheels available for Linux (x86_64, aarch64), macOS (x86_64, arm64), and musllinux; building from source requires PARI/GP >= 2.9.4 headers, GMP, C compiler, and pkg-config.

Verify before relying

  • Whether pre-built wheels include all PARI/GP functionality or if some features require compilation from source.
  • Performance characteristics compared to direct PARI/GP or other number theory libraries.
  • Stability and API compatibility guarantees across minor versions.

Package facts

License GPL-2.0-or-later (copyleft)
Python support supports the current Python release (>=3.12)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — cysignals
Maintenance actively maintained — 287 days since the last release
Last repo commit
First released
Downloads 126,161/month — #11,787 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cypari2-2.2.4-cp312-cp312-macosx_13_0_x86_64.whl; cypari2-2.2.4-cp312-cp312-macosx_15_0_arm64.whl; cypari2-2.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; cypari2-2.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; cypari2-2.2.4-cp312-cp312-musllinux_1_2_aarch64.whl; cypari2-2.2.4-cp312-cp312-musllinux_1_2_x86_64.whl; cypari2-2.2.4-cp313-cp313-macosx_13_0_x86_64.whl; cypari2-2.2.4-cp313-cp313-macosx_15_0_arm64.whl; cypari2-2.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; cypari2-2.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; cypari2-2.2.4-cp313-cp313-musllinux_1_2_aarch64.whl; cypari2-2.2.4-cp313-cp313-musllinux_1_2_x86_64.whl; cypari2-2.2.4-cp314-cp314-macosx_13_0_x86_64.whl; cypari2-2.2.4-cp314-cp314-macosx_15_0_arm64.whl; cypari2-2.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; cypari2-2.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; cypari2-2.2.4-cp314-cp314-musllinux_1_2_aarch64.whl; cypari2-2.2.4-cp314-cp314-musllinux_1_2_x86_64.whl; cypari2-2.2.4-cp314-cp314t-macosx_13_0_x86_64.whl; cypari2-2.2.4-cp314-cp314t-macosx_15_0_arm64.whl

Keywords: PARI/GP, number, theory

Tags

PARI/GP Python interfacenumber theory computationpolynomial factorizationalgebraic number theoryPARI bindings Pythoncomputational number theoryfinite field arithmetic
number-theorycryptography-researchcomputational-algebra

More Mathematics packages