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.4.tar.gz (19.8 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.4-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lunacept-0.4.4.tar.gz
  • Upload date:
  • Size: 19.8 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.4.tar.gz
Algorithm Hash digest
SHA256 64ae98eb0338b9efbedb149c353f5431b3dc7a89e5d9e883cf5839d4dfc0b463
MD5 24b9026fc8ee92445962aaa1963dedd8
BLAKE2b-256 71bf3484aafd2b2a41d8f9025a0b88b112cb4fca9d45f8826733b65a279b628e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lunacept-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 13.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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fddab816c5aafb2c190e0bf4870b15afdfd93339ee260f1b3aa3971056c65757
MD5 8f6eed2ae6d90e10b2e766e2e00b4f04
BLAKE2b-256 1d7c95f236316688ed8975ce55654c4919865c05f5bae1b087ef4882fd363e4a

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