Skip to content
Jay Lee edited this page May 30, 2021 · 19 revisions

Welcome to Decko wiki!

Decko is a decorator-based library designed for the following purposes

  1. Make the creation of decorators simple and reduce boilerplate
  2. Change the behavior of existing classes and function with minimal modifications
  3. Manage the state
  4. Provide a rich set of pre-made and tested decorators.

Updates / News

Self-contained decorators that can be used without creating a Decko instance is under development.

Install

Install and update using pip:

pip install -U decko

Uninstall

Uninstall using pip:

pip uninstall decko

API Overview

Decko's API is divided into two main parts.

decorators.py: This provides a rich set of pre-built decorators that can be used immediately in your projects. The main decorator is called deckorator, a utility decorator for creating decorators. To demonstrate its power, the code below is a simple timer() decorator that measures the runtime of a function without using deckorator.

import time


def timer(func):
    """
    An ordinary decorator.
    Will be used to check the
    performance of decorated function
    """
    def inner(*args, **kwargs):
        start_time = time.time()
        output = func(*args, **kwargs)
        elapsed = time.time() - start_time
        print(f"Time elapsed: {elapsed}")
        return output

    return inner


if __name__ == "__main__":

    @timer
    def create_list(n):
        return list(range(n))

    create_list(1000000)

Status: This wiki will be updated periodically as new features are added.

Updated on: May 30/05/21

Clone this wiki locally