Skip to main content

Line-by-line Python code profiler with optional memory tracking.

Project description

pywhipper

PyPI Version License: MIT

pywhipper is a lightweight, zero-dependency Python profiler designed for developers who want clear, line-by-line insights into the runtime and memory behavior of their code. With support for both function-level and block-level profiling, pywhipper is an ideal tool for rapid debugging and performance analysis.


📦 Installation

Install pywhipper directly from PyPI:

pip install pywhipper

🚀 Key Features

  • 🔍 Line-by-line execution time tracking
  • 🧠 Optional memory usage measurement (via tracemalloc)
  • 🧩 Profile entire functions with @whip
  • ⚡ Profile code blocks with with whip()
  • 📋 Clean, readable console outputs

🧪 Quick Start

Profile an Entire Function & Profile a Specific Code Block

from pywhipper import whip

# -------------------------------
# ✅ Approach 1 – Manual reverse
# -------------------------------

@whip(use_memory=True)
def reverse_string(s):
    string_list = list(s)
    left = 0
    right = len(string_list) - 1

    while left < right:
        string_list[left], string_list[right] = string_list[right], string_list[left]
        left += 1
        right -= 1
    return "".join(string_list)

string = 'sooraj'
print("Approach 1 result:", reverse_string(string))


# -------------------------------
# ✅ Approach 2 – Python slicing
# -------------------------------

with whip("Approach 2 slice reverse", use_memory=True):
    print("Approach 2 result:", string[::-1])

📊 Example Output

Profiling Function: reverse_string
Total Time: 0.000709 seconds
Memory measured in KB (approx)
------------------------------------------------------------
demo.py:9 | 0.000016s | +0.12 KB | string_list = list(s)
demo.py:10 | 0.000379s | +19.35 KB | left = 0
demo.py:11 | 0.000017s | +0.00 KB | right = len(string_list) - 1
demo.py:13 | 0.000017s | +0.00 KB | while left < right:
demo.py:14 | 0.000018s | +0.00 KB | string_list[left], string_list[right] = string_list[right], string_list[left]
demo.py:15 | 0.000019s | +0.00 KB | left += 1
demo.py:16 | 0.000017s | +0.00 KB | right -= 1
------------------------------------------------------------
Approach 1 result: jaroos

Timing block: Approach 2 slice reverse
Approach 2 result: jaroos
Done in 0.000037s | Memory: +0.45 KB


📌 License

This project is licensed under the MIT License.


🙋‍♂️ Author & Contributions

Developed by SOORAJ K K.


⭐️ Why pywhipper?

pywhipper is designed for developers who want just the right amount of visibility into their code's behavior — without the overhead or complexity of full-scale profilers. Whether you're debugging a slow function, understanding memory leaks, or optimizing a script, pywhipper makes performance transparent, fast, and actionable.


Thank you for using pywhipper.

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

pywhipper-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

pywhipper-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file pywhipper-0.1.0.tar.gz.

File metadata

  • Download URL: pywhipper-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pywhipper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34b99ccc9c4a9b2a3630410941446daf23f03d5266e019f156a03ebd823f249c
MD5 2a4738881df7f7975295a3018522a260
BLAKE2b-256 f3b7137cbef2a269fc5e86856a208957c8ad99eeb613e8cb3abd80226fbba6b6

See more details on using hashes here.

File details

Details for the file pywhipper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pywhipper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pywhipper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dec036c543b0d82619863c3030fc4765a3fdbd134bad1e1cdb6829aa43e8b279
MD5 bb3cdef4a15b1674245903f8668ce31c
BLAKE2b-256 fd5391c6aa56980ae63b740610ec27786ad8dc66aa87fed2d1c4cc0cd25d7d13

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