Registry / pyudorandom

pyudorandom

JSON →
library1.0.0pypypi✓ verified 87d ago

Pyudorandom is a Python library that generates pseudorandom sequences by using algebraic methods. It allows iteration over a list in a non-successive, yet deterministic way, ensuring each item is yielded exactly once. This is particularly useful when you need to mix up items without the overhead or cryptographic guarantees of true randomness, often outperforming `random.shuffle` for longer lists. The current version is 1.0.0, and releases are generally made on an as-needed basis.

pip install pyudorandom
INSTALL
IMPORT
SIG · PYUDORANDOM
P
pyudorandom
pythonv1.0.0
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pyudorandom
import pyudorandom
from pyudorandom import shuffle
The primary functions (shuffle, items, indices) are methods of the pyudorandom module itself, not directly importable symbols.

This example demonstrates how to use `pyudorandom.shuffle()` to obtain a new list with elements in a deterministic, non-successive order, and `pyudorandom.items()` to iterate through them.

import pyudorandom my_list = [1, 5, 7, 3, 2, 8, 4, 6] # Get a new list with elements in a 'pseudorandom' order shuffled_list = pyudorandom.shuffle(my_list) print(f"Original list: {my_list}") print(f"Shuffled list: {shuffled_list}") # Iterate through items in a 'pseudorandom' order print("\nIterating through items:") for item in pyudorandom.items(my_list): print(item)
Debug
Known issues
gotchaPyudorandom generates pseudorandom numbers deterministically, meaning given the same input, it will always produce the same sequence. It is not suitable for cryptographic purposes or applications requiring true unpredictability. For security-sensitive randomness, use Python's `secrets` module.
fix
Always understand the deterministic nature of pseudorandom generators. For cryptographic needs, use `import secrets` and functions like `secrets.randbelow()` or `secrets.token_hex()`.
affects: All
gotchaFor very small lists, `pyudorandom` might be slower than Python's built-in `random.shuffle`. This is due to its internal mechanism which involves finding a number `m` coprime to the list's length `n`.
fix
Benchmark for your specific use case. For small lists where performance is critical, `random.shuffle` might be a better choice. `pyudorandom` is optimized for significantly longer lists.
affects: All
Errors
Common errors & fixes
ImportError: cannot import name 'shuffle' from 'pyudorandom'
Attempting to import `shuffle` directly as if it were a top-level function in the module.
fix
The `shuffle` function is a method of the `pyudorandom` module itself. You should `import pyudorandom` and then call `pyudorandom.shuffle(my_list)`.
TypeError: object of type 'int' has no len()
Passing a non-iterable object (like an integer) to `pyudorandom.shuffle()` or `pyudorandom.items()`, which expect an iterable (e.g., list, tuple, string).
fix
Ensure you pass an iterable (e.g., a list or tuple) to `pyudorandom.shuffle()` or `pyudorandom.items()`. For example, `pyudorandom.shuffle([1, 2, 3])` works, but `pyudorandom.shuffle(123)` does not.
Upgrade
Version history
1.0.0latest on PyPI · released Jul 18, 2016
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
homepageUNKNOWN
pyudorandom — pip install pyudorandom · libregistry