This project has been archived by its maintainers, and is no longer receiving any updates.
Python decoratorbasic
Simple tools for creating and managing decorators in Python.
About The Project
Provides simple decorator utilities for Python 3.x.
Built With
Getting Started
To get a local copy up and running follow these simple example steps.
Prerequisites
- Python-lib - CallableType has been used for advanced type checking.
Installation
- Clone the repo
git clone https://github.com/TahsinCr/python-decoratorbasic.git
- Install PIP packages
pip install decoratorbasic
Usage
Let's create a decorator named Timer
from typing import Any, Callable, TypeVar, Generic
import time
from decoratorbasic import (
DecoratorBasic, get_decorator_callable, get_decorators
)
TCallable = TypeVar('TCallable', bound=Callable)
class TimerDecorator(DecoratorBasic[TCallable], Generic[TCallable]):
def definator(self, callable:TCallable):
print(f"Add Decorator '{callable.__name__}': '{self.__class__.__name__}'")
return callable
def decorator(self, callable:TCallable, *args, **kwargs):
self.start = time.time()
result = callable(*args, **kwargs)
self.end = time.time()
print(f"Result '{callable.__name__}': {self.end - self.start}")
return result
@TimerDecorator()
def test_range(start:int, stop:int):
for n in range(start, stop): ...
@TimerDecorator()
class testo:
def __init__(self):
for n in range(1, 10000000):...
test_range(1,4000000)
print('DecoratorFunction: {}; BaseFuntion: {}'.format(test_range, get_decorator_callable(test_range)))
print('Decorators: {}'.format(str(get_decorators(test_range))))
testo()
Output
Add Decorator 'test_range': 'TimerDecorator'
Add Decorator 'testo': 'TimerDecorator'
Result 'test_range': 0.06389307975769043
DecoratorFunction: <function test_range at 0x000001C8395540E0>; BaseFuntion: <function test_range at 0x000001C839161440>
Decorators: [<__main__.TimerDecorator object at 0x000001C8393C1400>]
Result '__init__': 0.1724531650543213
For more examples, please refer to the Documentation
License
Distributed under the MIT License. See LICENSE for more information.
Contact
Tahsin Çirkin - @TahsinCrs - TahsinCr@outlook.com
Project: TahsinCr/python-decoratorbasic
Metadata
Release files for decoratorbasic 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| decoratorbasic-1.0.1.tar.gz | 4.9 kB | Without provenance | Details for decoratorbasic-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| decoratorbasic-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for decoratorbasic-1.0.1-py3-none-any.whl |
Total release size: 10.0 kB
Release files / decoratorbasic-1.0.1.tar.gz
| Download URL | decoratorbasic-1.0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21afbbf10e7229f93ea78b695ae2529f875f78b8a760dfcce95b4c8c2541af9d
|
|
BLAKE2b-256 checksum How to use checksums |
53b86822e6d5b9937f781dfd1236a17963a1f57fc3d8217585c2abd0ad69c0a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / decoratorbasic-1.0.1-py3-none-any.whl
| Download URL | decoratorbasic-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
667d0eb938f8ed85a5dd92f0af5988b4b1296f27f72ddf5b6992482f6dadcc0b
|
|
BLAKE2b-256 checksum How to use checksums |
58c8830651eb89d542be19311d3a1a16b412f4e5baa8f1d5fbb412c84434041e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for decoratorbasic 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.