Skip to main content

tifa

Fast factorization of integers of up to about 220 bits (66 digits), with the TIFA C library: its quadratic sieve, elliptic curves and smaller methods, chosen by the size of the number.

>>> import tifa
>>> tifa.factor(360)
{2: 3, 3: 2, 5: 1}
>>> tifa.factor(2**64 + 1)
{274177: 1, 67280421310721: 1}
>>> tifa.factor(1)
{}

factor(n) returns the prime factorization of a positive integer as {prime: exponent}, primes in increasing order, like SymPy's factorint. n can be an int or any integer type with __index__ (NumPy's, gmpy2's).

Speed

One thread, balanced semiprimes (the hardest numbers of a size), on an AMD EPYC 9V45:

bits 100 140 180 220
tifa.factor 0.7 ms 9.6 ms 0.18 s 3.0 s
PARI/GP 2.15 factorint 1.9 ms 39 ms 0.55 s 9.0 s

Numbers with small factors take much less. From 180 to 220 bits the time doubles about every 10 bits, and keeps growing beyond.

Hints

When something is known of n, a hint saves time:

tifa.factor(n, hint="balanced")    # two primes of about the same size
tifa.factor(n, hint="unbalanced")  # a prime factor under a third of its size

A hint never changes the result, but a wrong one can cost much more time than none.

Threads

factor releases the GIL, so that threads factor in parallel:

from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor() as pool:
    results = list(pool.map(tifa.factor, numbers))

Errors

TypeError if n is not an integer, ValueError if it is not positive or the hint is unknown. In the rare event that n can not be factored completely, tifa.FactorizationError is raised, its factors attribute holding what was found (factors that multiply to n, some of them not prime).

Installing

From PyPI:

pip install tifa-factor

Wheels exist for Linux (x86-64 and arm64, glibc and musl) and macOS (arm64 and x86-64, 11.0 and later), for Python 3.10 and later; GMP comes in them. Elsewhere, pip builds the package from source.

From a checkout of TIFA, at the top of the tree:

pip install ".[test]"    # or "pip install ." without pytest
python -m pytest         # the tests

A build from source needs a C compiler, CMake 3.26 or later (pip fetches it if the system's is older) and GMP with its headers (libgmp-dev on Debian and Ubuntu, gmp-devel on Fedora, brew install gmp on macOS). A GMP installed elsewhere than in the usual places is found through GMP_ROOT, the directory holding its include and lib:

GMP_ROOT=/opt/gmp pip install .

Licence

LGPL 2.1 or later, as TIFA. The wheels contain GMP 6.3.0 (gmplib.org), under the LGPL 3 (readme/license_v3.txt), linked statically: pip install --no-binary tifa-factor tifa-factor builds the package against the GMP of the system instead.

Metadata

Release files for tifa-factor 0.4.6

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

Source distribution (sdist)

Source distribution for tifa-factor 0.4.6
File Size Uploaded Provenance Actions
tifa_factor-0.4.6.tar.gz 605.4 kB With provenance Details for tifa_factor-0.4.6.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tifa-factor 0.4.6
File Actions
tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_x86_64.whl
tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_aarch64.whl
tifa_factor-0.4.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for tifa_factor-0.4.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
tifa_factor-0.4.6-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.17+ ARM64 Details for tifa_factor-0.4.6-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
tifa_factor-0.4.6-cp310-abi3-macosx_11_0_x86_64.whl CPython 3.10 abi3 macOS 11.0+ x86-64 Details for tifa_factor-0.4.6-cp310-abi3-macosx_11_0_x86_64.whl
tifa_factor-0.4.6-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for tifa_factor-0.4.6-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 3.5 MB

Release files / tifa_factor-0.4.6.tar.gz

Download URL tifa_factor-0.4.6.tar.gz
Size 605.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2f76e37f79daa5da05864bb4216e37a5b1ea11e5ed9000c42517f8299c3c145f
BLAKE2b-256 checksum
How to use checksums
6438e1945799e3b3db1bcae21ddc778b3800c2fb4e3ca962d011ba3c037686c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_x86_64.whl
Size 527.6 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
d4a8df646f4ef203fd977eeccddb0463c28f339d1a973883a0d1235931cc7386
BLAKE2b-256 checksum
How to use checksums
815c441b94d249eed5e4af83f1c6d56f8db8e92e0678c88ad24f81f1a6f64054
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL tifa_factor-0.4.6-cp310-abi3-musllinux_1_2_aarch64.whl
Size 462.7 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
9a9350f3c884d222bb086f71f80b0b81f5a26abc023763f0ed824ca35c4acc56
BLAKE2b-256 checksum
How to use checksums
5b9e307508383023bbd9fd1573db6301952bb19ce9787a6d00ec70a32a807128
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / tifa_factor-0.4.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL tifa_factor-0.4.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 524.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c4e0a3a7e14cb10e3f29d489fd0709d400dc647d675b23f5a4af209c7932e6f9
BLAKE2b-256 checksum
How to use checksums
501ab19340566f6596bf87e5b18f0311ccf2bb62f8662f15f7f29880d2b77676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / tifa_factor-0.4.6-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL tifa_factor-0.4.6-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 458.3 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
fde683cafaae303ae648933d316cd7bc3dbbb4cfe7258c451d14ea65ddba29f8
BLAKE2b-256 checksum
How to use checksums
4b0b6bcda6c7dda7644f61cfe2399586f12f941179bae5529e0aee19738bb1e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / tifa_factor-0.4.6-cp310-abi3-macosx_11_0_x86_64.whl

Download URL tifa_factor-0.4.6-cp310-abi3-macosx_11_0_x86_64.whl
Size 510.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
1c3ffc850dd3583ed4c0ceabb4ece6c26f9ad6459fe6895c9557825896e6f540
BLAKE2b-256 checksum
How to use checksums
fbc2b0dd4721870ef5bce42f7d619c55f43c0eec327cdea852acb82dba21e64c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / tifa_factor-0.4.6-cp310-abi3-macosx_11_0_arm64.whl

Download URL tifa_factor-0.4.6-cp310-abi3-macosx_11_0_arm64.whl
Size 428.4 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a2f3ea40b52ca1f94730c08824ef8534a876a7d245a61bff7f87fc6378b187f4
BLAKE2b-256 checksum
How to use checksums
7f2f4c26eda428f2c5dcfe739c1b21f80fe16fbcdc278a074ff518ab44a1dbe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for tifa-factor 0.4.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for tifa_factor-0.4.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.6 This release

7 release files Full provenance

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