Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
.. image:: https://github.com/mgedmin/profilehooks/workflows/build/badge.svg?branch=master :target: https://github.com/mgedmin/profilehooks/actions
.. image:: https://ci.appveyor.com/api/projects/status/github/mgedmin/profilehooks?branch=master&svg=true :target: https://ci.appveyor.com/project/mgedmin/profilehooks
.. image:: https://coveralls.io/repos/mgedmin/profilehooks/badge.svg?branch=master :target: https://coveralls.io/r/mgedmin/profilehooks
It's a collection of decorators for profiling functions. E.g. to profile a single function::
from profilehooks import profile
@profile
def my_function(args, etc):
pass
The results will be printed when the program exits (or you can use
@profile(immediate=True)
).
If you're interested in coarse timings and don't want to pay for the overhead of profiling, use ::
from profilehooks import timecall
@timecall # or @timecall(immediate=True)
def my_function(args, etc):
pass
Finally, you may be interested in seeing line coverage for a single function ::
from profilehooks import coverage
@coverage
def my_function(args, etc):
pass
Also functions can be available in Python console or module if run it with -m arg ::
$ python -m profilehooks
>>> profile
<function profile at 0x1005c6488>
$ python -m profilehooks yourmodule
Full documentation is available through pydoc profilehooks
after
installation.
The home page for this module is https://mg.pov.lt/profilehooks. It has screensho, uh, that is, more examples.
Add support for Python 3.9, 3.10, 3.11, 3.12, and 3.13.
Drop support for Python 2.7, 3.5 and 3.6.
Drop support for hotshot
(which was only available for Python 2.7).
stdout
kwarg
of the @profile()
decorator and FuncProfiler()
constructor for
capturing output: https://github.com/mgedmin/profilehooks/pull/26.Fix breakage with @functools.lru_cache()
:
https://github.com/mgedmin/profilehooks/issues/25.
Use @functools.wraps()
so decorated functions now correctly set the
__wrapped__
attribute.
Add support for Python 3.8.
Detect Python source file encoding correctly in @coverage
.
https://github.com/mgedmin/profilehooks/issues/24.
New options: @timecall(log_name='logger', log_level=DEBUG)
.
https://github.com/mgedmin/profilehooks/pull/20.
Add Python 3.7 support.
Drop Python 3.3 and 3.4 support.
@timecall()
now defaults to the highest-precision timer
(timeit.default_timer()
) instead of time.time()
:
https://github.com/mgedmin/profilehooks/pull/11Drop claim of Python 3.2 compatibility. Everything still works, except I'm no longer running automated tests on 3.2, so things might regress.
Drop Python 2.6 compatibility.
Add Python 3.6 compatibility.
Include PID in temporary filenames: https://github.com/mgedmin/profilehooks/issues/6.
Claim Python 3.5 compatibility.
@profile(stdout=False)
to suppress output to sys.stdout.Make @profile(profiler='hotshot')
work again. This was probably broken
in 1.0 or 1.1, but nobody complained.
Fix missing space in the output of @profile(skip=N)
.
Make @coverage_with_hotshot
output match @coverage
output precisely.
100% test coverage.
Claim Python 3.4 and PyPy compatibility.
Explicitly claim Python 3.3 compatibility.
Fix Python 3.x bug with @coverage (stop using sys.maxint): https://github.com/mgedmin/profilehooks/issues/2.
Added Python 3.2 compatibility, dropped Python 2.3, 2.4 and 2.5 compatibility.
Migrated the source repository to https://github.com/mgedmin/profilehooks
Added a changelog.
New argument to @timecall: timer (defaults to time.time). Example: @timecall(timer=time.clock)
Better documentation.
New argument to: @timecall: immediate (defaults to False).
Added a test suite.
First release to PyPI, with a setup.py and everything.
New arguments to @profile: dirs, sort, entries. Contributed by Hanno Schlichting.
Preserve function attributes such as doc and module when decorating them.
Pydoc-friendly docstring wrapping and other docstring improvements.
Changed licence from GPL to MIT.
New decorator: @timecall
New arguments to @profile: skip, filename, immediate.
Added support for profile, after becoming convinced hotshot was unreliable. Made it the default profiler.
First public release (it didn't actually have a version number), announced on my blog: https://mg.pov.lt/blog/profiling.html
@profile and @coverage decorators that didn't accept any arguments.
hotshot was the only profiler supported for @profile, while @coverage used trace.py
FAQs
Decorators for profiling/timing/tracing individual functions
We found that profilehooks 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.