--- id: scalene version: "2.3.0" license: unclear license_treatment: permissive maintenance: active --- # scalene — Scalene: A high-resolution, low-overhead CPU, GPU, and memory profiler for Python with AI-powered optimization suggestions License: permissive · Maintenance: active · Downloads: 396.1K/mo ## What it is and what it does Scalene is a sampling-based profiler that measures CPU, GPU, and memory usage in Python programs at the line and function level. Unlike traditional profilers that instrument code or rely on Python's tracing hooks, Scalene uses sampling to keep overhead low while delivering detailed per-line breakdowns of where execution time and memory are consumed. It runs on macOS, Linux, and Windows, supports modern Python versions (3.8–3.14), and integrates with Jupyter, IPython, and VS Code. The package's distinguishing feature is AI-powered optimization suggestions: after profiling, users can click on specific lines or code regions to request optimization proposals from GPT-4, Azure, Amazon Bedrock, or local models via Ollama. Results are displayed in an interactive web-based GUI (or CLI) that works fully offline. Configuration is flexible—via command-line flags, YAML files, or programmatic decorators—making it suitable for one-off profiling runs and integrated performance monitoring in development workflows. Use it for: - Identify CPU and memory bottlenecks in data science pipelines and get AI-suggested rewrites before optimization effort - Profile GPU-accelerated code to see where computation time is spent and detect memory leaks on device - Integrate profiling into CI/CD to catch performance regressions at the line level across Python versions - Debug slow web services or batch jobs by profiling specific functions with the @profile decorator - Generate shareable performance reports as self-contained HTML files for code review and documentation ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Scalene profiles Python code to measure CPU, GPU, and memory consumption at the line level, and can generate AI-powered optimization suggestions for identified bottlenecks. Yes. Scalene is actively maintained, well-established (13k+ GitHub stars, top 15k PyPI packages), carries no known vulnerabilities, and solves a real problem—low-overhead, detailed profiling with AI-assisted optimization. The 9 runtime dependencies are standard and widely available. Install friction is moderate but manageable. Recommended for developers who need to understand and optimize Python performance without high profiling overhead. ## Install pip install scalene uv add scalene poetry add scalene ## Installing scalene Before you install: Medium install friction due to 9 runtime dependencies including numpy, pydantic, and nvidia-ml-py. Package is actively maintained with recent releases and strong community engagement (13494 GitHub stars). Precompiled wheels available for Python 3.8–3.14 on macOS, Linux, and Windows reduce build complexity. License in practice: Licensed under Apache License (permissive), allowing commercial and private use with minimal restrictions. No license-based constraints on adoption. Quickstart: pip install scalene # Profile a script scalene run your_prog.py # Or programmatically: from scalene import scalene_profiler scalene_profiler.start() # your code scalene_profiler.stop() Requires Python 3.8 or later (excluding 3.11.0). GPU profiling requires NVIDIA drivers and nvidia-ml-py. AI optimization suggestions require credentials for OpenAI, Azure, Amazon Bedrock, or a local Ollama instance. Verify before relying: - Whether AI optimization suggestions are available without external API credentials or if local-only operation is feasible - Performance overhead claim of 'typically no more than 10-20%' and accuracy comparison methodology - Compatibility with async/await code and multiprocessing workloads ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 396.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python cpu gpu memory profiler, line-level performance profiling, ai optimization suggestions python, python performance analysis tool, memory leak detection profiler, gpu profiling python, low-overhead python profiler, performance-profiling, ai-assisted-optimization, gpu-profiling [View on SkillFed](https://skillfed.io/packages/scalene) · [View on PyPI](https://pypi.org/project/scalene/)