Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

primer-kit-0.1.1a0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

primer_kit-0.1.1a0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file primer-kit-0.1.1a0.tar.gz.

File metadata

  • Download URL: primer-kit-0.1.1a0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • 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

Hashes for primer-kit-0.1.1a0.tar.gz
Algorithm Hash digest
SHA256 9b50e1c15a9081b11823203e033c9c475ac52d598ad9e8bdce8b2959488480ff
MD5 93fa3dcf2f5daa10e43943638bc02dd6
BLAKE2b-256 6f8893b47a7a774cbe1a398ce8e58568440c367dd72f985a4f51dc3997900520

See more details on using hashes here.

File details

Details for the file primer_kit-0.1.1a0-py3-none-any.whl.

File metadata

  • Download URL: primer_kit-0.1.1a0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 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

Hashes for primer_kit-0.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 8faa87470dd7fb58c626f2e76325ce99aaeae8eb1cef39a03ae9f56dc59e7dc7
MD5 30c00d65b411fa559a2eb7889301d182
BLAKE2b-256 dfcc9aa0984d2ffeb0c608fa0f711b3e7aa3670439519a732fc7ade6ab5d5e1e

See more details on using hashes here.

Supported by

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