MemoryLane 💾🛣️
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 CUDA memory measurement, and more to come.
- Minimal dependencies (just Rich + your favorite numerical library)
Installation
pip install memorylane[torch] # For PyTorch support
Usage
To use MemoryLane, just import it and decorate your function with @profile:
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:
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:11become 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 folder!
Metadata
Release files for memorylane 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memorylane-0.1.1.tar.gz | 7.5 kB | Without provenance | Details for memorylane-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memorylane-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for memorylane-0.1.1-py3-none-any.whl |
Total release size: 16.8 kB
Release files / memorylane-0.1.1.tar.gz
| Download URL | memorylane-0.1.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a07729a422a5f6d4048fc7985b511b785aad257b07a44209b027717220fc2dab
|
|
BLAKE2b-256 checksum How to use checksums |
cf29c347be9e39867eb9d983fad1afb31cf8164b90c267f53fc7fafa44661887
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / memorylane-0.1.1-py3-none-any.whl
| Download URL | memorylane-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b4072fc9e2abb374967509d0873cac99a3c0647e5b1537ffc287ca9f618ca84
|
|
BLAKE2b-256 checksum How to use checksums |
e5e348c794aae5bc3f0ec9b13b8faea8731901cae10bad72496001080b2f554e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for memorylane 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.