Skip to main content

🐧 penguin-py 🐧

Penguin is a lightweight, customizable stopwatch ⏱ decorator that helps you determine how long it takes for your functions to run. It supports both synchronous and asynchronous functions.

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.3.14

Usage

Synchronous Functions

For synchronous functions, use the @penguin() decorator.

✅ To run with default kwargs:

from penguin_py import penguin


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


test = foo("", test2="")

✅ To run with user specified kwargs:

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


test = foo("", 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 ().

from penguin_py import penguin


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


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

If you do this, you'll get a TypeError relating to arguments.

Asynchronous Functions

For asynchronous functions, use the @penguin_async() decorator.

✅ To run with default kwargs:

from penguin_py import penguin


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


test = foo("", test2="")

This will output the following to your logger:

Sample penguin output

✅ To run with user specified kwargs:

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


test = foo("", test2="")

This will output the following to your logger:

Sample penguin output kwargs

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"
  • log_level: The logging level to use for all log messages from this decorator (e.g., logging.DEBUG, logging.INFO, logging.WARNING).
    • default: logging.DEBUG

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.

Metadata

Release files for penguin-py 0.3.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for penguin-py 0.3.14
File Size Uploaded
penguin_py-0.3.14.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for penguin-py 0.3.14
File Interpreter ABI Platform
penguin_py-0.3.14-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / penguin_py-0.3.14.tar.gz

Download URL penguin_py-0.3.14.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a4800b4665cffa490ef84ff3d958fb2f78d815ac010a600b8b8288e6fdb9c30a
BLAKE2b-256 checksum
How to use checksums
11ab55501f76c12ef99f7a72f5be70b9a9f294b891b8c4d9f0d7474ee1e1724d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.6

Release files / penguin_py-0.3.14-py3-none-any.whl

Download URL penguin_py-0.3.14-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b28b83db3bd78ca22b77f8977e1b39b24379fc95b8954ad931e321630b67b42f
BLAKE2b-256 checksum
How to use checksums
a4ea55f76a7bd944eca72cf7d981bbd50f4a53253fe2e90a12e05804e5e70dce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.3.14 This release

2 release files

0.3.13

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page