![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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.
The source code of this package lives here: https://github.com/espitiaandres/penguin
To install penguin-py
with the command line, run this command:
pip install penguin-py
.
requirements.txt
fileTo install penguin-py
using a requirements.txt
file, add this line to your requirements.txt
file.
penguin-py==0.3.12
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.
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:
✅ 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:
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.
False
show_return
: When True
, it shows the function's return value(s).
False
foreground
: When chosen from this list, ["red", "yellow", "green", "blue", "magenta", "cyan", "grey"]
, it colour the logger output text the chosen colour.
"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.
"black"
Documentation of penguin-py
can be found here: https://github.com/espitiaandres/penguin/blob/master/README.md
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
Distributed under the terms of the MIT license, penguin-py
is free and open source software.
FAQs
Penguin: a customizable stopwatch decorator
We found that penguin-py demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.