# Readme of `yasiu-native`
## Installation
```shell
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.
```python
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
```python
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
```py
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
[1. Native Package](https://pypi.org/project/yasiu-native/)
[2. Math Package](https://pypi.org/project/yasiu-math/)
[3. Image Package](https://pypi.org/project/yasiu-image/)
[4. Pyplot visualisation Package](https://pypi.org/project/yasiu-vis/)
Raw data
{
"_id": null,
"home_page": null,
"name": "yasiu-native",
"maintainer": "Grzegorz Krug",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "kruggrzegorz@gmail.com",
"keywords": "time, timeit, measure time, decorators",
"author": "Grzegorz Krug",
"author_email": "kruggrzegorz@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/da/ce/9946b44eb5cbe44ba9c6b070cb22155bc5e4834943e9f3b5c13c753cc6d1/yasiu_native-0.2.2.tar.gz",
"platform": null,
"description": "# Readme of `yasiu-native`\n\n\n## Installation\n\n```shell\npip install yasiu-native\n```\n## Contains\n\nModule has plenty useful decorators.\n\n - Flexible decorators\n - Time decorators\n\n## Flexible decorator\n\nDecorator for parametrizing decorators.\n\nTurns single level decorator into two leveled decorator,\nby passing decoration parameters alongside function signature for ease of use.\n\nDecorators wrapped with `Flexible` can be used both with `()` and without `()` operator.\n\n### Example with one level parametrized decorator.\n```python\nfrom yasiu_native.decorators import flexible_decorator\n\n\n@flexible_decorator\ndef custom_decorator(func, decorParam):\n def wrapper(*a, **kw):\n print(f\"Decoration Paramter is {decorParam}\")\n return func(*a, **kw)\n\n return wrapper\n\n@custom_decorator\ndef test_1():\n pass\n\n@custom_decorator()\ndef test_2():\n pass\n\n@custom_decorator(1)\ndef test_3(b=0):\n pass\n\n@custom_decorator(decorParamA=1, decorParamB=2)\ndef test_3(b=0):\n pass\n\n```\n### Example with 2 level decorator\n```python\nfrom yasiu_native.decorators import flexible_decorator_2d\n\n@flexible_decorator_2d\ndef custom_decorator(*posParam, **keyParam):\n \"posParam: [Optional] positional argument for customizng your decorator behaviour\"\n \"keyParam: [Optional] keyword argument for customizng your decorator behaviour\"\n\n def wrapper(decoratedFunction):\n \"decoratedFunction: function To be decorated with your decorator.\"\n\n def inner(*args, **kwargs):\n \"args kwargs: arguments of decorated funciton\"\n \"Use decorative arguments to modify decorator\"\n\n ret = decoratedFunction(*args, **kwargs)\n return ret\n return inner\n return wrapper\n```\n\n## Time decorators\n\nDecorators for measuring time with formatter.\n\n- **measure_perf_time_decorator**\n\n decorator that measures function execution time using *time.perf_counter*\n\n\n- **measure_real_time_decorator**\n\n decorator that measures function execution time using *time.time*\n\n#### Measuring time\n\n```py\nfrom yasiu_native.time import measure_perf_time_decorator\n\n\n@measure_perf_time_decorator()\ndef func():\n ...\n\n\n@measure_perf_time_decorator(\">4.1f\")\ndef func():\n ...\n\n\n@measure_perf_time_decorator(fmt=\">4.1f\")\ndef func():\n ...\n\n\"Example output:\" # Function <name> executed in 3min\n\"Example output:\" # Function <name> executed in 40.2s\n\"Example output:\" # Function <name> executed in 10.2ms\n```\n\n#### Print buffering will impact your performance!\n\n- Use with caution for multiple function calls\n\n\n## Console execution timer\n\nnot here yet.\n\n# All packages\n\n[1. Native Package](https://pypi.org/project/yasiu-native/)\n\n[2. Math Package](https://pypi.org/project/yasiu-math/)\n\n[3. Image Package](https://pypi.org/project/yasiu-image/)\n\n[4. Pyplot visualisation Package](https://pypi.org/project/yasiu-vis/)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Native utilities based only on python builtins. Timers, Decorators.",
"version": "0.2.2",
"project_urls": {
"1. Native Package": "https://pypi.org/project/yasiu-native/",
"2. Math Package": "https://pypi.org/project/yasiu-math/",
"3. Image Package": "https://pypi.org/project/yasiu-image/",
"4. Visualisation Package": "https://pypi.org/project/yasiu-vis/",
"5. Source repo": "https://github.com/GrzegorzKrug/yasiu-native"
},
"split_keywords": [
"time",
" timeit",
" measure time",
" decorators"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "64e13ee12ff17b7a42056e88a95509b10ae71325a25ff52cc9554854190a4082",
"md5": "ac78a5009324a8cc4ebcb795abed1437",
"sha256": "7a32d08adf32f346949b1568972e92715ef9e016a86c39ce5be17c1a3fc76b3e"
},
"downloads": -1,
"filename": "yasiu_native-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ac78a5009324a8cc4ebcb795abed1437",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5437,
"upload_time": "2024-12-20T01:06:49",
"upload_time_iso_8601": "2024-12-20T01:06:49.091498Z",
"url": "https://files.pythonhosted.org/packages/64/e1/3ee12ff17b7a42056e88a95509b10ae71325a25ff52cc9554854190a4082/yasiu_native-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dace9946b44eb5cbe44ba9c6b070cb22155bc5e4834943e9f3b5c13c753cc6d1",
"md5": "35e9d4754bee0728dca573b2f245e8af",
"sha256": "20c3db57aa3998e76548ac0f2fed55d26baf019be51c91521e24865e3a87db87"
},
"downloads": -1,
"filename": "yasiu_native-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "35e9d4754bee0728dca573b2f245e8af",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6359,
"upload_time": "2024-12-20T01:06:51",
"upload_time_iso_8601": "2024-12-20T01:06:51.414144Z",
"url": "https://files.pythonhosted.org/packages/da/ce/9946b44eb5cbe44ba9c6b070cb22155bc5e4834943e9f3b5c13c753cc6d1/yasiu_native-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-20 01:06:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "GrzegorzKrug",
"github_project": "yasiu-native",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "yasiu-native"
}