You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e538bdb
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.en.md
+20-16Lines changed: 20 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,15 +22,14 @@
22
22
**PyCustomRand** is a self‑written Python library for generating **pseudo-random numbers**, based on an algorithm that utilizes system time with nanosecond precision.
23
23
24
24
This author's project was created to study algorithms and alternative approaches to random number generation and rounding.
25
-
I was not satisfied with the fact that Python's standard `random` module generates insufficiently random numbers ( *especially during multiple sequential generations* ), and the built-in `round` module rounds
26
-
numbers rather "roughly" ( *`round(1.5)` = 2 and at the same time `round(2.5)` = 2* ). Therefore, I decided to write *my own* library for pseudo-random number generation — simpler, with higher entropy and proper mathematical rounding.
25
+
I was not satisfied with the fact that Python's standard `random` module generates insufficiently high-entropy numbers ( *especially during multiple sequential generations* ), and the built-in `round` module rounds numbers rather "roughly" ( *`round(1.5)` = 2 and at the same time `round(2.5)` = 2* ), therefore I decided to write *my own* library — simpler, with higher entropy and mathematical rounding.
27
26
28
27
> [!WARNING]
29
28
> PyCustomRand is *currently***not** a cryptographically secure library and is **not intended** for use in security systems!
30
29
> Use the [secrets](https://docs.python.org/3/library/secrets.html#module-secrets) module for such purposes.
31
30
32
31
## 📌 Why use this library when Python has its own `random` and `round`?
33
-
PyCustomRand was written as an alternative to these two built-in modules. Here are the main features and capabilities of the library:
32
+
PyCustomRand was written as an alternative to these two built-in modules. Here are the main features and capabilities of the library, compared to them:
34
33
35
34
* The library is **simpler** to understand — the entire code is commented, lightweight, and clear. The PRNG (Pseudo-Random Number Generator) implementation is based on a *simple* algorithm using system time, making the library easy to customize, extend, or adapt to your needs.
36
35
* In most cases, PyCustomRand produces a more *"entropic"* result during sequential generations compared to the built-in `random` module.
@@ -68,17 +67,17 @@ PyCustomRand was written as an alternative to these two built-in modules. Here a
* The library also includes additional utilities useful for web/game development: generation of UUID v4, random HEX colors (e.g., `#ff05a1`), random bytes, random boolean values (`True`/`False`) with customizable probability.
78
-
*It features a custom rounding module — `true_round`. This function rounds numbers using the standard mathematical method (0.5 is always rounded up by magnitude) and also fixes floating-point errors (e.g., the "2.675 problem").
79
-
* The code is covered by unit tests (as indicated by the badge at the beginning of the README), and it has a built-in diagnostics module (`check_distribution`) allowing you to check the uniformity of the generator's distribution at any time.
77
+
*A custom rounding module, `true_round`, rounds numbers using the standard mathematical method (0.5 is always rounded up by magnitude) and also fixes floating-point errors (e.g., the "2.675 problem").
78
+
* The code is fully covered by unit tests (as indicated by the badge at the beginning of the README), and it has a built-in diagnostics module (`check_distribution`) allowing you to check the uniformity of the generator's distribution at any time.
80
79
81
-
However, the project does have some downsides:
80
+
It is worth noting that the project still has some minor drawbacks:
82
81
* Time-based randomness requires a small wait time (`time.sleep()` for 0.1 microseconds), so for massive iterations, PyCustomRand will be slightly slower than the built-in `random` module.
83
82
* Some functions in PyCustomRand (selection, distributions) are written so simply that they might not be fully optimized for massive samples (plus the accumulating micro-wait mentioned above).
84
83
@@ -100,9 +99,12 @@ pip install pycustomrand
100
99
* Download the package **directly** from the *Releases* section:
If you are modifying the library, and you constantly fail to check any one specific test, then you don't have to waste time running all the tests - you just need to run one specific test of a specific module, for example:
0 commit comments