randiter
randiter randomly iterates a sequence with buffered shuffling.
randiter is suitable for shuffling very long sequences and sequences with an unknown length.
Usage
Shuffle a very long sequence:
from randiter import randiter
for index in randiter(range(1_000_000_000)):
print(index) # random number
Shuffle lines in a text file with an unknown length:
from randiter import randiter
with open("large.txt", "rt") as f:
for line in randiter(f):
print(line) # random line
Shuffle a sequence with a large buffer size (to perform perfect shuffling, specify a buffer size that is equal to or greater than the length of the given sequence):
from randiter import randiter
for index in randiter(range(1_000_000_000), buffer_size=1_000_000):
print(index) # random number
FAQ
- Q. Shuffled sequences are not completely shuffled.
- A. This is because
randiterperforms buffered shuffling. This problem can be mitigated by specifying a larger buffer size.
- A. This is because
Metadata
Release files for randiter 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| randiter-0.1.0.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| randiter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.8 kB
Release files / randiter-0.1.0.tar.gz
| Download URL | randiter-0.1.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1489ed1aa4db99cd83466c81b75e954537a8a2e056da7d1da393ac67a65f49b8
|
|
BLAKE2b-256 checksum How to use checksums |
b911572066f6db2acb4adf4b023ac28942b0543e589b5c7d73cdb37d3f44956b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.9.7 Darwin/20.6.0
|
Release files / randiter-0.1.0-py3-none-any.whl
| Download URL | randiter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08ec0fca4e8f69ca65a257ccab6e873c2417253beb05b0a36836033bf49d626b
|
|
BLAKE2b-256 checksum How to use checksums |
8d38bafad4a16e9508f7cdfe6af67b4f204d9ef5615555f738a7233a6a32bc43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.9.7 Darwin/20.6.0
|