Native utilities based only on python builtins. Timers, Decorators.
Project description
Readme of yasiu-native
Installation
pip install yasiu-native
Contains
Module has plenty useful decorators.
- Flexible decorators
- Time decorators
Flexible decorator
Decorator for parametrizing decorators.
Turns single level decorator into two leveled decorator, by passing decoration parameters alongside function signature for ease of use.
Decorators wrapped with Flexible can be used both with () and without () operator.
Example with one level parametrized decorator.
from yasiu_native.decorators import flexible_decorator
@flexible_decorator
def custom_decorator(func, decorParam):
def wrapper(*a, **kw):
print(f"Decoration Paramter is {decorParam}")
return func(*a, **kw)
return wrapper
@custom_decorator
def test_1():
pass
@custom_decorator()
def test_2():
pass
@custom_decorator(1)
def test_3(b=0):
pass
@custom_decorator(decorParamA=1, decorParamB=2)
def test_3(b=0):
pass
Example with 2 level decorator
from yasiu_native.decorators import flexible_decorator_2d
@flexible_decorator_2d
def custom_decorator(*posParam, **keyParam):
"posParam: [Optional] positional argument for customizng your decorator behaviour"
"keyParam: [Optional] keyword argument for customizng your decorator behaviour"
def wrapper(decoratedFunction):
"decoratedFunction: function To be decorated with your decorator."
def inner(*args, **kwargs):
"args kwargs: arguments of decorated funciton"
"Use decorative arguments to modify decorator"
ret = decoratedFunction(*args, **kwargs)
return ret
return inner
return wrapper
Time decorators
Decorators for measuring time with formatter.
-
measure_perf_time_decorator
decorator that measures function execution time using time.perf_counter
-
measure_real_time_decorator
decorator that measures function execution time using time.time
Measuring time
from yasiu_native.time import measure_perf_time_decorator
@measure_perf_time_decorator()
def func():
...
@measure_perf_time_decorator(">4.1f")
def func():
...
@measure_perf_time_decorator(fmt=">4.1f")
def func():
...
"Example output:" # Function <name> executed in 3min
"Example output:" # Function <name> executed in 40.2s
"Example output:" # Function <name> executed in 10.2ms
Print buffering will impact your performance!
- Use with caution for multiple function calls
Console execution timer
not here yet.
All packages
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 yasiu_native-0.2.4.tar.gz.
File metadata
- Download URL: yasiu_native-0.2.4.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d0b65fb99b3976a16798d157a1809f8abd956dadf8122c10906d23efb29f1bd
|
|
| MD5 |
3c9ac330fd6b2aef19da14a30078697f
|
|
| BLAKE2b-256 |
262fb78076522e70bb61793177c0e2bfa37221ba66e859ce63115be31cc60542
|
Provenance
The following attestation bundles were made for yasiu_native-0.2.4.tar.gz:
Publisher:
python-publish.yml on GrzegorzKrug/yasiu-native
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yasiu_native-0.2.4.tar.gz -
Subject digest:
4d0b65fb99b3976a16798d157a1809f8abd956dadf8122c10906d23efb29f1bd - Sigstore transparency entry: 157137618
- Sigstore integration time:
-
Permalink:
GrzegorzKrug/yasiu-native@e3aef891c482d68d4a6852170426f581141be7d5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/GrzegorzKrug
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3aef891c482d68d4a6852170426f581141be7d5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file yasiu_native-0.2.4-py3-none-any.whl.
File metadata
- Download URL: yasiu_native-0.2.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de93fa4e200c07189063d9cfa71cbced8e109ba86dc1b24adcae777e32366904
|
|
| MD5 |
d10b266bdbda6e478f80bb85c422f2a2
|
|
| BLAKE2b-256 |
4fdcd4cf8fd9d46f20dc470f49a6fbe6fb302ebd79ab87b0500394130c7bd276
|
Provenance
The following attestation bundles were made for yasiu_native-0.2.4-py3-none-any.whl:
Publisher:
python-publish.yml on GrzegorzKrug/yasiu-native
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yasiu_native-0.2.4-py3-none-any.whl -
Subject digest:
de93fa4e200c07189063d9cfa71cbced8e109ba86dc1b24adcae777e32366904 - Sigstore transparency entry: 157137619
- Sigstore integration time:
-
Permalink:
GrzegorzKrug/yasiu-native@e3aef891c482d68d4a6852170426f581141be7d5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/GrzegorzKrug
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e3aef891c482d68d4a6852170426f581141be7d5 -
Trigger Event:
push
-
Statement type: