AgGarage
An open-source python package with multiple python tools.
Installation
pip install aggarage
Usage
from aggarage import *
@blitz # Example of a decorator from the package, it optimizes heavy calculations
def heavy_calc(x):
total = 0
for i in range(x):
total += i ** 2
return total
print(heavy_calc(10_000_000))
Timed Variables
AgGarage allows you to store variables over time and retrieve past values.
from aggarage import create_timed_variable, get_value_of_timed_variable, clear_all_timed_variables
create_timed_variable("score", 100)
create_timed_variable("score", 200)
print(get_value_of_timed_variable("score")) # latest value
print(get_value_of_timed_variable("score", "-1m")) # value 1 minute ago
clear_all_timed_variables() # removes all timed variable data
Utilities
AgGarage also provides common utility functions:
fib(n) – Fibonacci number
factorial(n) / factorial_recursive(n) – Factorial
is_prime(num) – Prime check
gcd(a, b) / lcm(a, b) – Greatest/common divisors
reverse_string(s) / is_palindrome(s) – String utilities
sum_of_squares(n) – Sum of squares
printf(text, color="red") – Colored terminal output
Notes
Timed variables are stored with second-level precision and automatically prune entries older than 30 minutes.
The @blitz decorator uses JIT compilation if available or threads as a fallback to speed up computations.
lightning
The @lightning decorator uses aggressive parallelization and multiprocessing to optimize performance for CPU-bound tasks.
It is much faster than @blitz for heavy computations but has more overhead, so it is best suited for very intensive tasks.
Use @lightning when you need maximum speedup for complex calculations that can be parallelized.
from aggarage import *
@lightning
def _heavy_computation_lightning(n):
total = 0
for i in range(n):
total += sum(j * j for j in range(1000))
return total
@blitz
def _heavy_computation_blitz(n):
total = 0
for i in range(n):
total += sum(j * j for j in range(1000))
return total
if __name__ == "__main__":
import time
n = 1000
start = time.time()
result_lightning = _heavy_computation_lightning(n)
end = time.time()
print(f"Lightning result: {result_lightning}, Time taken: {end - start:.4f} seconds")
start = time.time()
result_blitz = _heavy_computation_blitz(n)
end = time.time()
print(f"Blitz result: {result_blitz}, Time taken: {end - start:.4f} seconds")
Methods Comparison
| Method | First Run Time | Second Run Time | Notes |
|---|---|---|---|
| Lightning | 0.2033 seconds | 0.0000 seconds | Higher overhead, but excellent caching |
| Blitz | 0.0350 seconds | 0.0000 seconds | Good performance with caching |
| Standalone | 0.0338 seconds | 0.0336 seconds | Consistent but no caching benefits |
Result: 332,833,500,000 (all methods produce identical results)
Key Observations:
- Lightning has higher initial overhead but benefits significantly from caching
- Blitz provides good performance with minimal overhead
- Both decorators implement effective caching mechanisms
Release files for aggarage 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aggarage-0.4.5.tar.gz | 2.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aggarage-0.4.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.1 MB
Release files / aggarage-0.4.5.tar.gz
| Download URL | aggarage-0.4.5.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1dbc46ff0c638457bf9cb0c48e838aef40f8f1fcefec6cf4702d1f793134cfd
|
|
BLAKE2b-256 checksum How to use checksums |
8d4a7022579d13442eb0a19634dc8a22b0ea2f3b4e4f4b48954c9636e7a82b28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Release files / aggarage-0.4.5-py3-none-any.whl
| Download URL | aggarage-0.4.5-py3-none-any.whl |
|---|---|
| Size | 80.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
935a9dd58975efef375bfceb4c46286549b855277b14fd68be9cd47ca313b061
|
|
BLAKE2b-256 checksum How to use checksums |
bb0638b87c9f9bd9e54586d42cc9ddc6eaaaacc4d4233488cfd84d1553c8bf6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|