Skip to main content

Penguin: a customizable stopwatch decorator

Project description

🐧 Penguin_py 🐧

Penguin is a lightweight, customizable stopwatch ⏱ decorator that helps you determine how long it takes for your functions to run.

Source code

The source code of this package lives here: https://github.com/espitiaandres/penguin

Installation

With Command Line

To install penguin_py with the command line, run this command:

pip install penguin_py.

With a requirements.txt file

To install penguin_py using a requirements.txt file, add this line to your requirements.txt file.

penguin-py==0.2.6

Usage

✅ To run with default kwargs:

from penguin_py import penguin


@penguin()
def test_func(test1, test2=None):
    # NOTE: this function can be anything!
    for i in range(10000000):
        pass
    return "test", True


test = test_func("", test2=":")

✅ To run with user specified kwargs:

@penguin(
    verbose=True,
    show_args=True,
    show_return=True,
    foreground='cyan',
    background='yellow',
)
def test_func(test1, test2=None):
    for i in range(10000000):
        pass
    return "test", True


test = test_func("", test2=":")

Note: For a more detailed list of all kwargs and their defaults, visit this section: List of kwargs

❌ Since penguin is a decorator that takes in kwargs, do not call it without the brackets ().

@penguin
def test_func(test1, test2=None):
    # NOTE: this function can be anything!
    for i in range(10000000):
        pass
    return "test", True


test = test_func("", test2=":")

You'll get a TypeError relating to arguments.

List of kwargs

  • verbose: When True, it shows all logs that are described by the other kwargs. When False, each kwarg would determine if that specific log is shown
    • default: False
  • show_args: When True, it shows the function's signature, with the *args and **kwargs being passed in.
    • default: False
  • show_return: When True, it shows the function's return value(s).
    • default: False
  • foreground: When chosen from this list, ["red" "yellow", "green", "blue", "magenta", "cyan", "grey"], it colour the logger output text the chosen colour.
    • default: "grey"
  • background: When chosen from this list, ["red" "yellow", "green", "blue", "magenta", "cyan", "grey", "black", "white"], it colour the logger output background the chosen colour.
    • default: "black"

Documentation

Documentation of penguin_py can be found here: https://github.com/espitiaandres/penguin/blob/master/README.md

Bugs/Requests

If you find any bugs or have any suggestions to penguin_py, submit them in the issues tab in the Github repo. This can be found here: https://github.com/espitiaandres/penguin/issues

License

Distributed under the terms of the MIT license, penguin_py is free and open source software.

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

penguin_py-0.2.6.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

penguin_py-0.2.6-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file penguin_py-0.2.6.tar.gz.

File metadata

  • Download URL: penguin_py-0.2.6.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.12

File hashes

Hashes for penguin_py-0.2.6.tar.gz
Algorithm Hash digest
SHA256 8456cc320e6d1eeb80dc5ae767521df41902b605cc322fceae99202b8c2bd6d9
MD5 485ee1d24219f6e4ea9b88eadcb46c77
BLAKE2b-256 599d8454e84c9a816895e3dc4bf6c693eb53d8e158b4981432cbe3f491816488

See more details on using hashes here.

File details

Details for the file penguin_py-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: penguin_py-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.12

File hashes

Hashes for penguin_py-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0c4a310e07a4a99d5d5ba446e19f12b2a837489271fb278e26c1f809ec0cc4d5
MD5 a3f70d6c634c98c5f3139b20b6cbd6a0
BLAKE2b-256 f0b924068d98806fbea56febafb07b4c80a3194b42d18c03b994d6048d9777ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page