memorylane


Namememorylane JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummarySuper-lightweight line-by-line memory profiler for numerical Python code. See where those allocations are coming from! Supports NumPy, PyTorch, and more to come.
upload_time2025-08-04 18:51:01
maintainerNone
docs_urlNone
authorPeter Sharpe
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center"> MemoryLane 💾🛣️ </h1>

[![PyPI](https://img.shields.io/pypi/v/memorylane.svg)](https://pypi.python.org/pypi/memorylane)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://opensource.org/license/apache-2-0)

by Peter Sharpe

-----

A super-lightweight line-by-line memory profiler for numerical Python code. See where those pesky allocations are coming from!
* Supports [PyTorch](https://pytorch.org/) CUDA memory measurement, and more to come.
* Minimal dependencies (just [Rich](https://github.com/Textualize/rich) + your favorite numerical library)

## Installation

```bash
pip install memorylane[torch]  # For PyTorch support
```

## Usage

To use MemoryLane, just import it and decorate your function with `@profile`:

```python
import torch
from memorylane import profile

@profile
def my_function():
    x = torch.randn(5120, 5120, device="cuda")
    x = x @ x
    x = x.relu()
    x = x.mean()
    return x

my_function()
```

This will print your line-by-line memory usage:

![terminal](./examples/make_report/memorylane_report.svg)

## Features

* For complicated functions, filter the report to only show lines with non-negligible changes in memory usage: `@profile(only_show_significant=True)`
* When used from terminal via most editors (e.g., VSCode/Cursor, PyCharm, etc.), the printouts like `make_reports.py:11` become clickable links that will take you directly to the offending line in your code
* Profiling of multiple functions, including nested ones (these will be shown with indentation, to allow you to see where the allocations are coming from)
* Report generation in HTML and text formats
* (Work in progress) Support for measuring memory usage of:
    * PyTorch CPU operations
    * NumPy operations
    * JAX operations
    * Python whole-process memory usage
    * ...and more!

## Examples

Under construction - for now, see the [examples](./examples) folder!
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "memorylane",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Peter Sharpe",
    "author_email": "Peter Sharpe <peterdsharpe@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/cf/29/c347be9e39867eb9d983fad1afb31cf8164b90c267f53fc7fafa44661887/memorylane-0.1.1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\"> MemoryLane \ud83d\udcbe\ud83d\udee3\ufe0f </h1>\n\n[![PyPI](https://img.shields.io/pypi/v/memorylane.svg)](https://pypi.python.org/pypi/memorylane)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://opensource.org/license/apache-2-0)\n\nby Peter Sharpe\n\n-----\n\nA super-lightweight line-by-line memory profiler for numerical Python code. See where those pesky allocations are coming from!\n* Supports [PyTorch](https://pytorch.org/) CUDA memory measurement, and more to come.\n* Minimal dependencies (just [Rich](https://github.com/Textualize/rich) + your favorite numerical library)\n\n## Installation\n\n```bash\npip install memorylane[torch]  # For PyTorch support\n```\n\n## Usage\n\nTo use MemoryLane, just import it and decorate your function with `@profile`:\n\n```python\nimport torch\nfrom memorylane import profile\n\n@profile\ndef my_function():\n    x = torch.randn(5120, 5120, device=\"cuda\")\n    x = x @ x\n    x = x.relu()\n    x = x.mean()\n    return x\n\nmy_function()\n```\n\nThis will print your line-by-line memory usage:\n\n![terminal](./examples/make_report/memorylane_report.svg)\n\n## Features\n\n* For complicated functions, filter the report to only show lines with non-negligible changes in memory usage: `@profile(only_show_significant=True)`\n* When used from terminal via most editors (e.g., VSCode/Cursor, PyCharm, etc.), the printouts like `make_reports.py:11` become clickable links that will take you directly to the offending line in your code\n* Profiling of multiple functions, including nested ones (these will be shown with indentation, to allow you to see where the allocations are coming from)\n* Report generation in HTML and text formats\n* (Work in progress) Support for measuring memory usage of:\n    * PyTorch CPU operations\n    * NumPy operations\n    * JAX operations\n    * Python whole-process memory usage\n    * ...and more!\n\n## Examples\n\nUnder construction - for now, see the [examples](./examples) folder!",
    "bugtrack_url": null,
    "license": null,
    "summary": "Super-lightweight line-by-line memory profiler for numerical Python code. See where those allocations are coming from! Supports NumPy, PyTorch, and more to come.",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e5e348c794aae5bc3f0ec9b13b8faea8731901cae10bad72496001080b2f554e",
                "md5": "6df1c28d86182e1eff43014d534c8ef8",
                "sha256": "6b4072fc9e2abb374967509d0873cac99a3c0647e5b1537ffc287ca9f618ca84"
            },
            "downloads": -1,
            "filename": "memorylane-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6df1c28d86182e1eff43014d534c8ef8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 9334,
            "upload_time": "2025-08-04T18:51:00",
            "upload_time_iso_8601": "2025-08-04T18:51:00.000548Z",
            "url": "https://files.pythonhosted.org/packages/e5/e3/48c794aae5bc3f0ec9b13b8faea8731901cae10bad72496001080b2f554e/memorylane-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cf29c347be9e39867eb9d983fad1afb31cf8164b90c267f53fc7fafa44661887",
                "md5": "b8e6e1aa85db5ffd26c68564066534d2",
                "sha256": "a07729a422a5f6d4048fc7985b511b785aad257b07a44209b027717220fc2dab"
            },
            "downloads": -1,
            "filename": "memorylane-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b8e6e1aa85db5ffd26c68564066534d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7493,
            "upload_time": "2025-08-04T18:51:01",
            "upload_time_iso_8601": "2025-08-04T18:51:01.078257Z",
            "url": "https://files.pythonhosted.org/packages/cf/29/c347be9e39867eb9d983fad1afb31cf8164b90c267f53fc7fafa44661887/memorylane-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-04 18:51:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "memorylane"
}
        
Elapsed time: 2.05276s