No project description provided
Project description
fastpy-rs
FastPy-RS is a high-performance Python library that provides optimized implementations of common functions using Rust. It's designed to be a collection of frequently used functions where performance matters, offering significant speed improvements over pure Python implementations.
Features
- Blazing Fast: Leverages Rust's performance to provide significant speedups
- Easy to Use: Simple Python interface
- Growing Collection: New functions are added regularly
Currently Available Functions
-
Token Frequency Counter
- Counts word frequencies in a text (case-insensitive)
- Example:
{"hello": 2, "world": 1}for input "Hello hello world"
-
Base64 Encoding
- Encodes binary data to base64 string
- Example:
base64_encode(b"hello")returnsb'aGVsbG8='
Installation
pip install fastpy-rs
Or from source:
pip install maturin
maturin develop
Usage
from fastpy_rs import ai
# Count word frequencies in a text
text = "Hello hello world! This is a test. Test passed!"
frequencies = ai.token_frequency(text)
print(frequencies)
# Output: {'hello': 2, 'world': 1, 'this': 1, 'is': 1, 'a': 1, 'test': 2, 'passed': 1}
Performance
Token Frequency Counter
Performance comparison between the Rust implementation and a Python implementation using spaCy, a popular industrial-strength NLP library:
Performance Test Results (average time per call):
Rust implementation: 0.000207 seconds
Python implementation: 0.014828 seconds
Speedup: 71.66x
The test compares the tokenization and frequency counting of a text sample. The Rust implementation shows a significant performance improvement over the Python/spaCy implementation, being approximately 71.66x faster in our tests. Note that spaCy provides additional NLP features beyond simple tokenization, while our Rust implementation is optimized specifically for the token frequency counting task.
Base64 Encoding
Performance comparison between the Rust implementation and Python's built-in base64 module:
Base64 Performance Test Results (average time per call):
Rust implementation: 0.00006026 seconds
Python implementation: 0.00003622 seconds
Speedup: 0.60x
Note: While the Rust implementation is currently slightly slower than Python's highly optimized built-in base64 module, it's included for completeness and may be optimized further in future updates.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
- Install Rust: https://www.rust-lang.org/tools/install
- Install maturin:
pip install maturin - Clone the repository
- Build in development mode:
maturin develop - Run tests:
pytest tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Roadmap
📦 JSON / Data
-
parse_json(string) -> dict -
serialize_json(obj, pretty=False) -> str -
parse_large_json_file(filepath) -> dict -
extract_json_field(json_str, path: str) -> Any(JSONPath-like) -
compare_json(json1, json2) -> bool -
validate_json(schema: dict, data: dict) -> bool -
minify_json(json_str: str) -> str -
pretty_print_json(json_str: str) -> str -
merge_json_objects(json1: dict, json2: dict) -> dict -
flatten_json(nested_dict: dict) -> dict
🌐 HTTP / Networking
-
http_get(url, headers=None, timeout=10) -> str -
http_post(url, data, headers=None) -> str -
http_download(url, dest_path) -
http_request(method, url, headers, body) -> (code, body) -
fetch_json(url) -> dict -
http_head(url) -> headers -
http_retry_request(...) -
http_stream_lines(url) -> Iterator[str] -
http_check_redirect_chain(url) -> List[str] -
http_measure_latency(url) -> float
🔐 Hashing / Crypto
-
sha256(data: bytes | str) -> str -
md5(data: bytes | str) -> str -
hmac_sha256(key, message) -> str -
blake3_hash(data) -> str -
is_valid_sha256(hexstr: str) -> bool -
secure_compare(a: str, b: str) -> bool
🧮 Data Processing / Encoding
-
base64_encode(data: bytes) -> str -
base64_decode(data: str) -> bytes -
gzip_compress(data: bytes) -> bytes -
gzip_decompress(data: bytes) -> bytes -
url_encode(str) -> str -
url_decode(str) -> str -
csv_parse(csv_string) -> List[Dict] -
csv_serialize(data: List[Dict]) -> str -
bloom_filter_create(size: int, hash_funcs: int) -
bloom_filter_check(item: str) -> bool
⏱️ Performance / Utils
-
benchmark_fn(callable, *args, **kwargs) -> float -
parallel_map(func, list, threads=4) -> list -
fast_deduplication(list) -> list -
sort_large_list(list) -> list -
fuzzy_string_match(a, b) -> score -
levenshtein_distance(a, b) -> int -
tokenize_text(text: str) -> List[str] -
fast_word_count(text: str) -> Dict[str, int] -
regex_search(pattern, text) -> List[str] -
regex_replace(pattern, repl, text) -> str
🧠 AI/ML Preprocessing
-
normalize_vector(vec: List[float]) -> List[float] -
cosine_similarity(vec1, vec2) -> float -
token_frequency(text: str) -> Dict[str, int] -
encode_text_fast(text: str) -> List[int]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 fastpy_rs-0.0.4-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fastpy_rs-0.0.4-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 693.7 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d4059d0f36290df64cc37150f88225920d14bb6b808d5c66f7fe1f1be6cda26
|
|
| MD5 |
5d75ac11cf0fd7cc550161373c8b0828
|
|
| BLAKE2b-256 |
41e01db9c27cd0409a8d37a60f94887145f4552f3d558a8c09d52ace1ae21b8d
|