SquareRoot2Py
https://www.youtube.com/watch?v=ktRwfBMV4S8
The SquareRoot2Py package aims to remove the hassle of computing the square root of 2.
Features
- computing the square root of 2
- up to 16 decimal places of precision
- cross-platform support
- O(1) algorithm
- clear and concise naming
Installation
pip install SquareRoot2Py
Benchmark
Our state-of-the-art algorithm computes the rounded value of the square root of 2 almost 2x faster than the built-in C implementation.
Built-in C implementation
>>> timeit("a = round(2 ** 0.5)", number=10000000)
0.46002930000031483
SquareRoot2Py
>>> timeit("a = SquareRoot2Py.RoundedSquareRoot2Py.compute_rounded_square_root_of_2()", setup="import SquareRoot2Py.RoundedSquareRoot2Py", number=10000000)
0.26070590000017546
Examples
To compute the square root of 2 easily:
import SquareRoot2Py
print(SquareRoot2Py.compute_square_root_of_2())
If you would like to round the result:
import SquareRoot2Py.RoundedSquareRoot2Py
print(RoundedSquareRoot2Py.compute_rounded_square_root_of_2())
For more complex usecases such as calculating the US Government Budget, adjustable rounding can be used:
import SquareRoot2Py.SquareRoot2PyWithAdjustableRounding
print(SquareRoot2Py.SquareRoot2PyWithAdjustableRounding.compute_square_root_of_2_with_adjustable_rounding(3))
We are aware that the name SquareRoot2Py.SquareRoot2PyWithAdjustableRounding might be too long
Therefore, the following alias is introduced:
import SquareRoot2Py
print(SquareRoot2Py.WithAdjustableRounding.compute_square_root_of_2_with_adjustable_rounding())
Metadata
Release files for SquareRoot2Py 2.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 | |
|---|---|---|---|
| squareroot2py-2.1.0.tar.gz | 39.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| SquareRoot2Py-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 67.3 kB
Release files / squareroot2py-2.1.0.tar.gz
| Download URL | squareroot2py-2.1.0.tar.gz |
|---|---|
| Size | 39.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c247994922a514ce36a194d16ca22d6580ae5ede8a606486b959a51cce172a2
|
|
BLAKE2b-256 checksum How to use checksums |
d01cc75f65b87f8a9a47b3d0cac1e0faa66828ee0dffe7c203c82b5affb0f4ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / SquareRoot2Py-2.1.0-py3-none-any.whl
| Download URL | SquareRoot2Py-2.1.0-py3-none-any.whl |
|---|---|
| Size | 27.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd150d2546e81f5cc30580ab51798a713d85fad48198fdbbf6251b8ee27d51f0
|
|
BLAKE2b-256 checksum How to use checksums |
734dcf3c2dd5f78fece73b75fbaf53d83684f2e6fabecf86d5f85f6a42487654
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|