Skip to main content

Python-FLINT

Python extension module wrapping FLINT (Fast Library for Number Theory) and Arb (arbitrary-precision ball arithmetic). Features:

  • Integers, rationals, integers mod n
  • Real and complex numbers with rigorous error tracking
  • Polynomials, power series and matrices over all the above types
  • Lots of mathematical functions

Documentation: http://fredrikj.net/python-flint/

Repository: https://github.com/flintlib/python-flint/

Author: Fredrik Johansson fredrik.johansson@gmail.com

Installation

For Windows (x86-64) or OSX (x86-64 or arm64) or Linux (x86-64 manylinux_2_17) there are binary wheels for python-flint on PyPI. For these platforms python-flint can be installed simply with pip

pip install python-flint

Alternatively python-flint can be installed using conda

conda install -c conda-forge python-flint

Build from source

For other platforms or architectures installation needs to build from source. First install both FLINT 2.9.0 and Arb 2.23. Note that for python-flint 0.4 only these exact versions of FLINT and Arb will work. While some Linux distributions may provide FLINT and Arb it is unlikely that they will provide the exact versions required (e.g. for Ubuntu only Ubuntu 23.04 provides these versions at the time of writing).

See here for instructions on building FLINT and Arb:

The latest release of Python-FLINT can then be built and installed using:

pip install 'cython>=3' numpy wheel
pip install --no-build-isolation python-flint

Python-FLINT can also be installed from a git checkout or a source archive as follows:

pip install 'cython>=3' numpy wheel
pip install --no-build-isolation .

A script that builds and installs FLINT, Arb and Python-FLINT that is tested on Ubuntu can be found in the git repo here:

See the documentation for further notes on building and installing Python-FLINT:

Examples

Import Python-FLINT:

>>> from flint import *

Number-theoretic functions:

>>> fmpz(1000).partitions_p()
24061467864032622473692149727991
>>> fmpq.bernoulli(64)
-106783830147866529886385444979142647942017/510

Polynomial arithmetic:

>>> a = fmpz_poly([1,2,3]); b = fmpz_poly([2,3,4]); a.gcd(a * b)
3*x^2 + 2*x + 1
>>> a = fmpz_poly(list(range(10001))); b = fmpz_poly(list(range(10000))); a.gcd(a * b).degree()
10000
>>> x = fmpz_poly([0,1]); ((1-x**2)*(1+x**3)**3*(1+x+2*x)).factor()
(-1, [(3*x + 1, 1), (x + (-1), 1), (x^2 + (-1)*x + 1, 3), (x + 1, 4)])

Matrix arithmetic:

>>> fmpz_mat([[1,1],[1,0]]) ** 10
[89, 55]
[55, 34]
>>> fmpq_mat.hilbert(10,10).det()
1/46206893947914691316295628839036278726983680000000000

Numerical evaluation:

>>> showgood(lambda: (arb.pi() * arb(163).sqrt()).exp() - 640320**3 - 744, dps=25)
-7.499274028018143111206461e-13
>>> showgood(lambda: (arb.pi() * 10**100 + arb(1)/1000).sin(), dps=25)
0.0009999998333333416666664683

Numerical integration:

>>> ctx.dps = 30
>>> acb.integral(lambda x, _: (-x**2).exp(), -100, 100) ** 2
[3.141592653589793238462643383 +/- 3.11e-28]

To do

  • Write more tests and add missing docstrings
  • Wrap missing flint types: finite fields, p-adic numbers, multiprecision integer mods, rational functions
  • Vector or array types (maybe)
  • Many convenience methods
  • Write generic implementations of functions missing for specific FLINT types
  • Proper handling of special values in various places (throwing Python exceptions instead of aborting, etc.)
  • Various automatic conversions
  • Conversions to and from external types (numpy, sage, sympy, mpmath, gmpy)
  • Improved printing and string input/output
  • IPython hooks (TeX pretty-printing etc.)

CHANGELOG

0.5.0

  • gh-63: The roots method of arb_poly, and nmod_poly is no longer supported. Use acb_roots(p).roots() to get the old behaviour of returning the roots as acb. Note that the roots method of fmpz_poly and fmpq_poly currently returns the complex roots of the polynomial.

License

Python-FLINT is licensed MIT. FLINT and Arb are LGPL v2.1+.

Release files for python-flint 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-flint 0.4.3
File Size Uploaded
python-flint-0.4.3.tar.gz 2.5 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for python-flint 0.4.3
File
python_flint-0.4.3-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
python_flint-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
python_flint-0.4.3-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
python_flint-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
python_flint-0.4.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
python_flint-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
python_flint-0.4.3-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
python_flint-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
python_flint-0.4.3-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
python_flint-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
python_flint-0.4.3-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
python_flint-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details

Total release size: 185.2 MB

Release files / python-flint-0.4.3.tar.gz

Download URL python-flint-0.4.3.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
e536b3c0fbe5139840600039460aaaeba93923371b28ac1db2dbf24e644472d0
BLAKE2b-256 checksum
How to use checksums
007bba6ed7b1d1870f32f95e90c7adcbfc1cfe4766bb9a4eb9f4734aaa94b20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp311-cp311-win_amd64.whl

Download URL python_flint-0.4.3-cp311-cp311-win_amd64.whl
Size 12.5 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e76a6988bfc8624eb75923c517254f55ee62077fdb1c03a858bdf0fcfd161d83
BLAKE2b-256 checksum
How to use checksums
8f2a6402c7b1c851a540e963661f647725f45a231bf5d09033e062f286e697dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_flint-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 35.8 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e3ece5c256590ea4f1f1f812e32cfa3dc39b0694acff2c0436dc9a0bbee7e059
BLAKE2b-256 checksum
How to use checksums
f513a0c9ad0c04902eb56fad8e0f3509155f13c24383614a123e4d791489ea6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp311-cp311-macosx_11_0_arm64.whl

Download URL python_flint-0.4.3-cp311-cp311-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0621dc2ec6aebf5aefb9da40c43ab508ef8637ea07a8c0a11a02a91dbdd4039d
BLAKE2b-256 checksum
How to use checksums
1af552ce87c1d0f2afd763941a11b03be6e82eba76dd425a396ebde3caa66452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl

Download URL python_flint-0.4.3-cp311-cp311-macosx_10_9_x86_64.whl
Size 7.1 MB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f8e5c6092fdb8ee1bafa8edd977d1b6edc70e1792bc0561e280eb20ac485f91e
BLAKE2b-256 checksum
How to use checksums
d372c5416c545d18eee9c0196cd97a3bbf83d65611bad7fb0a1bf24e6b10a493
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp310-cp310-win_amd64.whl

Download URL python_flint-0.4.3-cp310-cp310-win_amd64.whl
Size 12.5 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
a5f967ae04b446355c2855feecaee0853b5810829310a567b834e9b1637e4ae7
BLAKE2b-256 checksum
How to use checksums
56f5971ff096446fd648d7a82780140dee05f4aa3f51faaf32daed88a40724ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_flint-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 35.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
62baa418ec4c487379ccfe07462764f6544d51c200aec3ba8bbdddf547326e6b
BLAKE2b-256 checksum
How to use checksums
6780eb020f358cb925983375e3450b4ba829dd5900d4965155275e8711457cde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp310-cp310-macosx_11_0_arm64.whl

Download URL python_flint-0.4.3-cp310-cp310-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f775f1dab4ddb63799d6efc1d2e1775bfdb07fbb2e79faa0fea83926dd1ba717
BLAKE2b-256 checksum
How to use checksums
5329b4f5c07fe122acc64c7e98a5ff0dfaa6f95586a6e16d3f0d54e5b3c321da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl

Download URL python_flint-0.4.3-cp310-cp310-macosx_10_9_x86_64.whl
Size 7.1 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
0517318af2079cc54ee817da508945f2bd525d504344eb66501508c246759b8b
BLAKE2b-256 checksum
How to use checksums
c6d5563786119f01f3aee6930b7b7ed37d3ce19a3f8fc8a28312e10e43197494
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp39-cp39-win_amd64.whl

Download URL python_flint-0.4.3-cp39-cp39-win_amd64.whl
Size 12.5 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
cf7832fcaebff5424be882e05e2db4ab1a297a83eaf036dce5d532466ede138e
BLAKE2b-256 checksum
How to use checksums
d0736afda0e46fa46cde14aace5de7f4683726876ee186a5149ee2ac2d1d69d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_flint-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 35.1 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8f62ef6ff49f9ffaf63c9a2bfa9cd93876b56a180f76760ddf4ecd063b8d4b20
BLAKE2b-256 checksum
How to use checksums
d45f05aa5a1d54e22df675876478c9dbd6dbdf0eb1f66d3f803f0d8f367bfb67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp39-cp39-macosx_11_0_arm64.whl

Download URL python_flint-0.4.3-cp39-cp39-macosx_11_0_arm64.whl
Size 6.0 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6a062518739d2f1d836c891555fb22f8e70cc0985ad889b9f5f783526c0635b8
BLAKE2b-256 checksum
How to use checksums
04802d2ad2d07c70e9b1fd9322e63cd66ad726b46f725ec7c7cdd9416c7606a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / python_flint-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl

Download URL python_flint-0.4.3-cp39-cp39-macosx_10_9_x86_64.whl
Size 7.1 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
b9b73444e271924bd95ad0e1428eac081e5d58d06edcb7f851143661f6904ca0
BLAKE2b-256 checksum
How to use checksums
24a50652f830a4266d0d4c9d613ade885b52373b83be2aa550be070bc0aa32d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3
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