Skip to main content

Ultra-fast odd-only prime lookup with memory-mapped cache

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.0.tar.gz (8.1 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.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lookprime-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 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.0.tar.gz
Algorithm Hash digest
SHA256 275ed80fdc0606783870987283a46657fc7d913a540c3da2742906687896cc76
MD5 b11589b828e02f4fc67a1f9705875e12
BLAKE2b-256 41a95c3acaffdaec84319eb4da8a63d6321df18f3d67536e18d34ac56f69c9ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lookprime-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 630cf43809b50773eb8f974c194db364133dfaa8be9ff925cca7c1bd5a934354
MD5 fecc895d4432916d1b505a2ab54eed8f
BLAKE2b-256 f03387f43f1a94e64d87cdfe23e21d20612473091582a78f81bffa831d46d0ba

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