Primer is a lightweight toolbox for debugging and benchmarking Python code.
Project description
Primer
Primer is a lightweight toolkit for debugging and benchmarking Python code.
With only one line inserted, primer improves your coding experience.
from primer import debug, profile, performance
Install
Requirements
- Python >= 3.5
pip install primer-kit
Debug
Exception hook helps you debug your code whenever exception is raise.
debug.setup_hook()
Call decorator monitors every call to the function and its arguments.
@debug.call
def my_function(args):
Profile
Time and memory profilers measure the duration and memory allocation for some code.
with profile.time(), profile.memory():
They can also be used as decorators over functions. A log frequency of 10 outputs results once per 10 calls.
@profile.time(log_frequency=10)
def my_function(args):
Performance
Slot decorator converts all member variables to static slots, which saves memory and runs faster.
@performance.slot
class MyClass(object):
Shared ndarray can be passed across processes without copy, which saves memory by several times and runs faster.
import numpy as np
import multiprocessing as mp
arrays = [performance.SharedNDArray(np.random.rand(100000)) for _ in range(4)]
results = mp.Pool(4).map(np.sum, arrays)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file primer_kit-0.1.0a0-py3-none-any.whl
.
File metadata
- Download URL: primer_kit-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9834d9d7e916eef32c0cf109ff862182d1ba860a2f936f8c86cd594b0629145 |
|
MD5 | 1fb2fcb07db6bc326bf5524f1bda1b15 |
|
BLAKE2b-256 | d5f34194899cfd1addaf8a7d74884710bd83c44be6fd46f89c569a856e0972d7 |