High-performance math functions implemented in C for Python.
Project description
pyfastmath
🚀 pyfastmath is a blazing-fast math utility module for Python, written in C for maximum performance. It includes essential number-theoretic functions like GCD, primality checking, modular exponentiation and many more. Check below for more information about the features.
✨ Features
gcd(a, b)– Compute the Greatest Common Divisor of two integersis_prime(n)– Efficiently check if a number is primemod_exp(base, exp, mod)– Perform Modular Exponentiation: (base^exp) % modlcm(a, b)– Calculate the Lowest Common Multiplicantfactorial(n)– Calculate the factorial of a positive integerncr(n, r)– Calculate the combination of two number(nCr)npr(n, r)– Calculate the permutation of two number(nPr)
⚙️ Installation
After building locally:
pip install .
Or after uploading to PyPI:
pip install pyfastmath
🧪 Usage
import pyfastmath
print(pyfastmath.gcd(48, 18)) # ➝ 6
print(pyfastmath.is_prime(97)) # ➝ True
print(pyfastmath.mod_exp(2, 10, 100)) # ➝ 24
print(pyfastmath.lcm(48, 18)) # ➝ 144
print(pyfastmath.factorial(5)) # ➝ 120
print(pyfastmath.ncr(5,2)) # ➝ 10
print(pyfastmath.npr(5, 2)) # ➝ 20
Documentation
See the full documentation from here Docs
🚧 Requirements
- Python 3.6 or higher
- C compiler (e.g. gcc, clang, MSVC)
💠 Build from Source
python setup.py sdist bdist_wheel
pip install dist/pyfastmath-<version>.whl
📦 Distribute via PyPI
pip install twine
twine upload dist/*
📜 License
This project is licensed under the MIT License.
Contribution
See the contribution guidelines guidelines
👨💻 Author
Built with ❤️ by Gourabananda Datta B.Tech CSE, Ramkrishna Mahato Government Engineering College
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfastmath-1.1.2.tar.gz.
File metadata
- Download URL: pyfastmath-1.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7271f2f9a3bcf4f5c225c859375814279d1517905e6b00acfb95a7a793fb5bac
|
|
| MD5 |
94a7b19d2ee8e06550c16a9d41772fb9
|
|
| BLAKE2b-256 |
47b0cd3527521f34073fa93647d4dd84d6c79b523b305943dd76e2ee5caa6bc9
|
File details
Details for the file pyfastmath-1.1.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyfastmath-1.1.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 9.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f41057a53c56e513af35eba052fb37a7bb6daae9a72feca5b64c2262216c512f
|
|
| MD5 |
0f07277f7b39f4a867d2c89ee72fa2b9
|
|
| BLAKE2b-256 |
a32540e629f566f470addcc7682562020176ff0d7a08157f96d367f54b15b89c
|