Skip to main content

Enhanced exception analysis library for Python - prints detailed information about what happened when an exception occurs

Project description

Lunacept

Lunacept is an enhanced exception analysis library for Python. It automatically instruments your code to capture and display the values of intermediate expressions when an exception occurs, making debugging significantly easier.

Instead of just telling you where an error happened, Lunacept tells you why by showing you the runtime values of every part of the failing expression.

Lunacept Example

Highlights

  • Show the values of all sub-expressions at the exact position (line and column) that caused the exception.

  • Easy to use - no need to modify your existing code.

  • Low Overhead, benchmark results show overhead between 1.1x and 1.4x:

Installation

pip install lunacept

Usage

Simply import lunacept and call install():

import lunacept

def main():
    # Your existing code - no changes needed

if __name__ == "__main__":
    lunacept.install()
    main()

You can also use the @capture_exceptions decorator to instrument specific functions:

from lunacept import capture_exceptions

@capture_exceptions
def your_function():
    ...

How It Works

Lunacept uses Python's ast (Abstract Syntax Tree) module to parse and transform your code at runtime. It breaks down complex expressions into temporary variable assignments, allowing it to track the value of each sub-expression individually. When an exception occurs, Lunacept uses these captured values to generate a detailed report.

Performance

Lunacept is designed to be lightweight, but since it instruments code at runtime, there is some overhead. Below are benchmark results comparing standard execution vs. Lunacept instrumentation (MacBook Pro, Apple M1, 16GB RAM):

Test Case Baseline Instrumented Slowdown
Simple Math (Arithmetic Loop) 0.052 ms 0.068 ms 1.3x
Recursive Fib (Function Calls) 0.062 ms 0.089 ms 1.4x
Complex Logic (Branching) 0.049 ms 0.056 ms 1.1x

The overhead is generally between 1.1x and 1.4x

License

This project is licensed under the MIT License.

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

lunacept-0.4.7.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lunacept-0.4.7-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file lunacept-0.4.7.tar.gz.

File metadata

  • Download URL: lunacept-0.4.7.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for lunacept-0.4.7.tar.gz
Algorithm Hash digest
SHA256 305abbdbb80b93beb45a24f156701e3a9237126e9a5d827f5cb28b09dc323aa6
MD5 0062c83dd6ba88bae6e8d2fb0e38db46
BLAKE2b-256 5e03b39d02ac5cdd06053d345d6b4057c19efb5782a4996fadffdff7b9241cb2

See more details on using hashes here.

File details

Details for the file lunacept-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: lunacept-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for lunacept-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ec4d6cf63ff07225f9eeb7222419d7192c32e14a75ef2a8eebaa9346d5964bbd
MD5 a035aab1d421061524c9ea4d5f742bb0
BLAKE2b-256 a83702af62f6a067508cb94f78c360de1b60bf6f1e2bb76b92bdb45d63109faf

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