Skip to main content

Ultra-fast prime lookup using memory-mapped odd-only sieve

Project description

lookprime

Ultra-fast odd-only prime lookup using a byte mask, with memory-mapped cache.

Install

pip install lookprime

CLI

Build (writes to cache by default):

lookprime build --limit 100000000

Benchmark (uses cached mask if present; otherwise builds & caches):

lookprime benchmark --limit 100000000 --duration 1.0 --iterations 25

Benchmark using a specific mask file:

lookprime benchmark --mask /path/to/lookprime_mask_100000000.lpm

Python Usage

from lookprime import open_mask, sieve_to_cache, count_primes_for_duration

path = sieve_to_cache(100_000_000)         # build or reuse cache
mask = open_mask(path)                     # mmap open

hits, max_n = count_primes_for_duration(mask, duration=1.0, start_n=1, chunk=32768)
print(hits, max_n)

mask.close()

Project details


Download files

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

Source Distribution

lookprime-0.1.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lookprime-0.1.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file lookprime-0.1.2.tar.gz.

File metadata

  • Download URL: lookprime-0.1.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lookprime-0.1.2.tar.gz
Algorithm Hash digest
SHA256 20032dac26a5949c36e52fcab50ddf1a89a380251368685efd635c920bf47b87
MD5 859028d00cfdfcf1c1b542c686571d2f
BLAKE2b-256 2682d9d4e67d6d2cd5430e2b296715bd9bf7696290b3347240cbf0ae61666f11

See more details on using hashes here.

File details

Details for the file lookprime-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: lookprime-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lookprime-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13a4efdc81ed0737c73cec66caa9102f8202051bf58f634626adccca4728f236
MD5 95dcbc6be281764d9859e022b52f2620
BLAKE2b-256 e047f10c0f2c1eed225cd50e48ef3bf4d0618bc14d711ec97f661a69eaa8ea86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page