Skip to main content

Iterate randomly over integer ranges

Project description

Shuffled: Random iterators for large integer ranges

Shuffled is a library for iterating randomly and without repetition over integer ranges. It doesn’t store all the integers in memory so that you can work with ranges of up to 2128 elements, even with your standard RAM available.

Installation

pip install shuffled

Usage

Example: Generating a permutation of integers.

>>> from shuffled import Shuffled
>>> shuffled_range = Shuffled(10)
>>> list(shuffled_range)
[4, 1, 2, 9, 8, 5, 3, 0, 6, 7]
>>> same_shuffled_range = Shuffled(10, seed=shuffled_range.seed)
>>> list(same_shuffled_range)
[4, 1, 2, 9, 8, 5, 3, 0, 6, 7]

Example: Listing all IP addresses in a subnet in random order.

>>> import ipaddress
>>> from shuffled import Shuffled
>>> network = ipaddress.IPv4Network('10.0.0.0/8')
>>> shuffled_range = Shuffled(network.num_addresses)
>>> for index in shuffled_range:
...     print(network[index])
...
10.24.41.126
10.67.199.15
10.240.82.199
10.79.219.74
10.166.105.25
10.19.5.91
# Continues for all 16M addresses in the subnet

Release

  • Update the changelog.
  • Bump the version identified in pyproject.toml.
  • After those changes are merged into main, tag the commit on main and push it.
    • The CI/CD process will publish the new package version on PyPI.

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

shuffled-1.2.0.tar.gz (66.0 kB view details)

Uploaded Source

Built Distribution

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

shuffled-1.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file shuffled-1.2.0.tar.gz.

File metadata

  • Download URL: shuffled-1.2.0.tar.gz
  • Upload date:
  • Size: 66.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shuffled-1.2.0.tar.gz
Algorithm Hash digest
SHA256 488e1826363074942a64f5d1cdbd04308e7737b61bec33935543f6b913caaf1a
MD5 45c00a6beabfd68a97207cdb392b2552
BLAKE2b-256 a91b9c64bc6a86ea44200fc01a985327613fbc0eef5cec5d051508e41fcbb2a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for shuffled-1.2.0.tar.gz:

Publisher: main.yml on bbc2/shuffled

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shuffled-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: shuffled-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for shuffled-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1836956b18976f4f7af6c74ba0cdb1d855504e0fbf90e4bb6f374cb2378ee9f5
MD5 58b0c977c294b148c37dcf7fed2d3280
BLAKE2b-256 d1ba787c1067d6bc30c7cfbba1a8d0c10214d48bfa9cbcbeb3a63e65ce6063c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for shuffled-1.2.0-py3-none-any.whl:

Publisher: main.yml on bbc2/shuffled

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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