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 onmainand 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
488e1826363074942a64f5d1cdbd04308e7737b61bec33935543f6b913caaf1a
|
|
| MD5 |
45c00a6beabfd68a97207cdb392b2552
|
|
| BLAKE2b-256 |
a91b9c64bc6a86ea44200fc01a985327613fbc0eef5cec5d051508e41fcbb2a3
|
Provenance
The following attestation bundles were made for shuffled-1.2.0.tar.gz:
Publisher:
main.yml on bbc2/shuffled
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shuffled-1.2.0.tar.gz -
Subject digest:
488e1826363074942a64f5d1cdbd04308e7737b61bec33935543f6b913caaf1a - Sigstore transparency entry: 1574175818
- Sigstore integration time:
-
Permalink:
bbc2/shuffled@89bc37c8f5fd13a2c0028627d50d8978ffd4c5bf -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/bbc2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@89bc37c8f5fd13a2c0028627d50d8978ffd4c5bf -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1836956b18976f4f7af6c74ba0cdb1d855504e0fbf90e4bb6f374cb2378ee9f5
|
|
| MD5 |
58b0c977c294b148c37dcf7fed2d3280
|
|
| BLAKE2b-256 |
d1ba787c1067d6bc30c7cfbba1a8d0c10214d48bfa9cbcbeb3a63e65ce6063c1
|
Provenance
The following attestation bundles were made for shuffled-1.2.0-py3-none-any.whl:
Publisher:
main.yml on bbc2/shuffled
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shuffled-1.2.0-py3-none-any.whl -
Subject digest:
1836956b18976f4f7af6c74ba0cdb1d855504e0fbf90e4bb6f374cb2378ee9f5 - Sigstore transparency entry: 1574176114
- Sigstore integration time:
-
Permalink:
bbc2/shuffled@89bc37c8f5fd13a2c0028627d50d8978ffd4c5bf -
Branch / Tag:
refs/tags/1.2.0 - Owner: https://github.com/bbc2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@89bc37c8f5fd13a2c0028627d50d8978ffd4c5bf -
Trigger Event:
push
-
Statement type: