https://github.com/bbc2/shuffled
Python random permutations of large integer ranges
https://github.com/bbc2/shuffled
cryptography iterator python randomization
Last synced: about 2 months ago
JSON representation
Python random permutations of large integer ranges
- Host: GitHub
- URL: https://github.com/bbc2/shuffled
- Owner: bbc2
- License: mit
- Created: 2016-05-29T17:10:32.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2025-02-09T12:33:15.000Z (4 months ago)
- Last Synced: 2025-03-25T14:39:04.602Z (2 months ago)
- Topics: cryptography, iterator, python, randomization
- Language: Python
- Size: 152 KB
- Stars: 10
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.```python
>>> 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]
``````python
>>> 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
[...]
```