Skip to main content

Repackage python-flint to include arb and flint as shared libraries

Project description


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



Author: Fredrik Johansson


First install both FLINT (version 2.5 or later) and Arb (version 2.15 or later). See:

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

pip install python-flint

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

pip install .

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


Import Python-FLINT:

>>> from flint import *

Number-theoretic functions:

>>> fmpz(1000).partitions_p()
>>> fmpq.bernoulli(64)

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()
>>> 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()

Numerical evaluation:

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

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.)
  • Windows support


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

Project details

Download files

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

Files for flint-py, version 0.3.4
Filename, size File type Python version Upload date Hashes
Filename, size flint_py-0.3.4-cp27-cp27m-manylinux1_x86_64.whl (17.4 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size flint_py-0.3.4-cp27-cp27mu-manylinux1_x86_64.whl (17.4 MB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size flint_py-0.3.4-cp34-cp34m-manylinux1_x86_64.whl (17.6 MB) File type Wheel Python version cp34 Upload date Hashes View
Filename, size flint_py-0.3.4-cp35-cp35m-manylinux1_x86_64.whl (17.6 MB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size flint_py-0.3.4-cp36-cp36m-manylinux1_x86_64.whl (17.6 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size flint_py-0.3.4-cp37-cp37m-manylinux1_x86_64.whl (17.6 MB) File type Wheel Python version cp37 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page