Skip to main content

A set of debugging decorators

Project description

PyDebug

This is a simple set of utilities which makes it easier to debug Python objects. Pydebug respects Django's config. It checks if the decorator is running within a Django project and DEBUG is set to True. If it's set to False, it simply returns the function.

Installing

You can install by cloning this repository and running pip install . within this directory, or you can install through Pypi, by running pip install python-pydebug.

Requirements

Although Pydebug uses Python's standard library, it tried to import Django to make sure you are not within a Django project.

Library Defaults
Cython -
IPDB PDB
Line-profiler -

Line-profiler requires Cython to work, if IPDB is not found, it fallsback to Python's standard PBD library.

Usage

PDBDebugger

from pydebug import PDBDebugger

@PDBDebugger()
def hello_world(a, b):
    x = a + b
    return (a, b)

You may tell PDBdebugger to drop a IPDB shell only when an error occurs

from pydebug import PDBDebugger

@PDBDebugger(on_error=True)
def hello_world(a, b):
    x = a + b
    return (a, b)

DisassembleDebug

You may disassemble a Python function by using the Disassembledebug decorator.

from pydebug import Disassembledebug

@DisassembleDebug()
def hello_world(a, b):
    x = a + b
    return (a, b)

Profilerdebug

Profilerdebug uses Python's default cProfile library.

from pydebug import ProfilerDebug

@ProfilerDebug()
def hello_world(a, b):
    x = a + b
    return (a, b)

LineProfilerDebug

LineProfilerDebug requires line-profile library to work, which also requires Cython.

from pydebug import LineProfilerDebug

@LineProfilerDebug()
def hello_world(a, b):
    x = a + b
    return (a, b)

ObjectInfoDebug

ObjectInfoDebug prints the arguments which were passed to the function, the performace counter (in minutes), the process time (in minutes) and the returned objects by the function.

from pydebug import ObjectInfoDebug

@ObjectInfoDebug()
def hello_world(a, b):
    x = a + b
    return (a, b)

TODOs

  1. Allow developer to use multiple decorators instead of one decorating the other
  2. Show better profile metrics
  3. Plot metrics to an image

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

python-pydebug-0.3.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file python-pydebug-0.3.tar.gz.

File metadata

  • Download URL: python-pydebug-0.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for python-pydebug-0.3.tar.gz
Algorithm Hash digest
SHA256 f91c3bb3996dd2cef17a931594160ae72662f69627a51f9f0e1dc8f6145c0c9b
MD5 7ffba99fc93ab73dea20154661b8ce19
BLAKE2b-256 88688f99eebdf75c25a0b904be6c8f34a6d4e64c9e065dbafe5bb859da6a688e

See more details on using hashes here.

Supported by

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