A Python interface to the number theory library PARI/GP
Project description
A Python interface to the number theory library PARI/GP.
Installation
From a distribution package (GNU/Linux, conda-forge)
A package might be available in your package manager, see https://repology.org/project/python:cypari2/versions or https://doc.sagemath.org/html/en/reference/spkg/cypari for installation instructions.
From a pre-built wheel from PyPI
Requirements:
Python >= 3.9
pip
Install cypari2 via the Python Package Index (PyPI) via
$ pip install cypari2 [--user]
(the optional option –user allows to install cypari2 for a single user and avoids using pip with administrator rights).
From source with pip
Requirements:
PARI/GP >= 2.9.4 (header files and library); see https://doc.sagemath.org/html/en/reference/spkg/pari#spkg-pari for availability in distributions (GNU/Linux, conda-forge, Homebrew, FreeBSD), or install from source.
Python >= 3.9
pip
cysignals >= 1.11.3
Cython >= 3.0
Install cypari2 via the Python Package Index (PyPI) via
$ pip install --no-binary cypari2 cypari2 [--user]
(the optional option –user allows to install cypari2 for a single user and avoids using pip with administrator rights).
pip builds the package using build isolation. All Python build dependencies of the package, declared in pyproject.toml, are automatically installed in a temporary virtual environment.
If you want to try the development version, use
$ pip install git+https://github.com/sagemath/cypari2.git [--user]
Usage
The interface as been kept as close as possible from PARI/GP. The following computation in GP
? zeta(2) %1 = 1.6449340668482264364724151666460251892 ? p = x^3 + x^2 + x - 1; ? modulus = t^3 + t^2 + t - 1; ? fq = factorff(p, 3, modulus); ? centerlift(lift(fq)) %5 = [ x - t 1] [x + (t^2 + t - 1) 1] [ x + (-t^2 - 1) 1]
translates into
>>> import cypari2 >>> pari = cypari2.Pari() >>> pari(2).zeta() 1.64493406684823 >>> p = pari("x^3 + x^2 + x - 1") >>> modulus = pari("t^3 + t^2 + t - 1") >>> fq = p.factorff(3, modulus) >>> fq.lift().centerlift() [x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]
The object pari above is the object for the interface and acts as a constructor. It can be called with basic Python objects like integer or floating point. When called with a string as in the last example the corresponding string is interpreted as if it was executed in a GP shell.
Beyond the interface object pari of type Pari, any object you get a handle on is of type Gen (that is a wrapper around the GEN type from libpari). All PARI/GP functions are then available in their original names as methods like zeta, factorff, lift or centerlift above.
Alternatively, the pari functions are accessible as methods of pari. The same computations be done via
>>> import cypari2 >>> pari = cypari2.Pari() >>> pari.zeta(2) 1.64493406684823 >>> p = pari("x^3 + x^2 + x - 1") >>> modulus = pari("t^3 + t^2 + t - 1") >>> fq = pari.factorff(p, 3, modulus) >>> pari.centerlift(pari.lift(fq)) [x - t, 1; x + (t^2 + t - 1), 1; x + (-t^2 - 1), 1]
The complete documentation of cypari2 is available at http://cypari2.readthedocs.io and the PARI/GP documentation at http://pari.math.u-bordeaux.fr/doc.html
Contributing
CyPari 2 is maintained by the SageMath community.
Open issues or submit pull requests at https://github.com/sagemath/cypari2 and join https://groups.google.com/group/sage-devel to discuss.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file cypari2-2.2.0.tar.gz
.
File metadata
- Download URL: cypari2-2.2.0.tar.gz
- Upload date:
- Size: 127.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 817606bf661b71d33e1d012421907a4f8fb09dd81b7d3e3ae179b3978020bbf1 |
|
MD5 | 00d38dbe51a0db04a4e0c6a198229f1b |
|
BLAKE2b-256 | 87c0a31ff1e6354aaa6a689f1d501b629f459fc5853bced216dad8477a5a6a01 |
File details
Details for the file cypari2-2.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 34.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f24b1b647c5e1be15d4cf7876af727b1e77c53b12fa1bf50624c3e9ed25a349 |
|
MD5 | 202529ed927c97d7e4826ccb0973d97e |
|
BLAKE2b-256 | 38188b07c1284e3af5f3d99952f9791bafac8767f7792113d6e87fbf82034aa1 |
File details
Details for the file cypari2-2.2.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 32.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2cabbe6220eee9f23511670888fe6925376c1656871fb242d954508f8cc6223 |
|
MD5 | 1544820b25ba6265977efa258724bb5a |
|
BLAKE2b-256 | 71b14f14dde91d2c42ec955d74347977ffdb1cd7ea52b8653d3a6150f5aab9a1 |
File details
Details for the file cypari2-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7525e3cdff6228dbfea8ef84df6a4ce969d7abfdc6c79801f50f20c18df29168 |
|
MD5 | b41fd26404459b6d7246376e6eb8d198 |
|
BLAKE2b-256 | 90024f02ee457dce118e19d63f88ecba5adc144fb18b9402993d7f1fac218b6e |
File details
Details for the file cypari2-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 34.9 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f74a0e133056ca4975b4628dad43bc4002022a56ef29e5fc3a106c06cafe4606 |
|
MD5 | 4b86fdf86d713557b267d9d012c7398f |
|
BLAKE2b-256 | 8056d3df35f78504515b467324b1d0e4c63036d4258774b8def3d33af276a355 |
File details
Details for the file cypari2-2.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 32.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 464fc17f3db972a4110dd190cc39630cc6ac6592bec24e53e93e334eb30ca735 |
|
MD5 | e2eeb25857f69ecc85455648b20073b0 |
|
BLAKE2b-256 | 9e22b18fefb509098d190b1a820d0c5722edb7de84a24ec61ab6ec5f62a89f2d |
File details
Details for the file cypari2-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a8a1af1e7aea0c6c9537913e6a95d31a03f030da697ba4eb290ec2cd35ac61 |
|
MD5 | 96c253899cff33891dfd566b7192ff66 |
|
BLAKE2b-256 | 3a0adf65d02c94a3509c5d300ec63ebe23ec1a573abc10c29a2ce7dc93e11055 |
File details
Details for the file cypari2-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 34.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55d340d0436b966993bfdee189bb6f9392f6ca84fe67f766b09582a9f17eac0e |
|
MD5 | 6fa29ad7dadd4d5258cd59badea97c1e |
|
BLAKE2b-256 | 64807d33ecaa5e8e939b13306b4fad7be6671c82ab34fd2b789dc3f6be86ba7d |
File details
Details for the file cypari2-2.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 31.5 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 656ddfb50395c9bc266e62b530ddb7eb30ebd8f477a7267e1b20c2e39c902bd2 |
|
MD5 | 881cb216235a5247898ce209aca8c20a |
|
BLAKE2b-256 | 8e400e17b73364436c308d6126b14d344833a5fcdccfeb5cb862375a25b76ba6 |
File details
Details for the file cypari2-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0e349c6ac08c2e515fc3179431f874c667495aa25d5c0097157b44b6712e50c |
|
MD5 | 923cd6274db1aacc26ee43c63ec48dc2 |
|
BLAKE2b-256 | eff011d998de6610daf0d8db05d5145b0218d93c861395d84a43a35c1fe8a287 |
File details
Details for the file cypari2-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 34.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88db3231b21f3907278f801667bce45b6a539ac9f4104ddf563775114d7962e |
|
MD5 | ae985ff465dc75f9323a362e2faeda4d |
|
BLAKE2b-256 | 0939acc54656947b2a47265615f5f9e8454cc04dceca5488ac872c6a133076bb |
File details
Details for the file cypari2-2.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 31.5 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec591ca129f8d70b87399e5cff10f9536271786bc4378801e0cc2d630245fc46 |
|
MD5 | 7890eb6311538e600bfe84173d21c439 |
|
BLAKE2b-256 | 6ddf29f3436d351a49c52bf6c2dc8954f34260e35d741c8747c07ba11182fd17 |
File details
Details for the file cypari2-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: cypari2-2.2.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa29690934e1b799ba2940c5ed60ceeabe19a31f38b8f5cfb75d1170bed185e3 |
|
MD5 | f24b53b5b7101ac6a52d2625cf66a66a |
|
BLAKE2b-256 | d9be34d2f05ea8f78261c4f725f84a26a4f168287938bce8cf4e8a02ba81ee70 |