Skip to content

Config


dataclass linescope.config.Config[source]

Configure a single profiling session.

Parameters

backend : str | Backend, default=default_backend()

Built-in backend member, its string value, or a registered engine name. Default to Trace on Python 3.11-3.15. Select scalene for Python 3.11-3.14 sampling or tachyon for Python 3.15 sampling.

memory : bool, default=False

Collect process RAM and retained Python allocation changes separately, using the shared memory collector.

gpu : bool, default=False

Collect supported Scalene GPU utilization and device memory. Trace warns and continues Python profiling without GPU measurements.

sample_rate : int | None, default=None

Target samples per second for Scalene or Tachyon. None preserves the backend default of 1000 for Scalene and Tachyon. Higher rates increase collection overhead. Trace ignores this setting. The achieved rate can differ depending on operating-system timer resolution and scheduling settings.

root : str | None, default=None

Project directory; otherwise discover the nearest pyproject.toml.

include : tuple[str, ...], default=()

Package names, filesystem paths, or project-relative glob patterns.

exclude : tuple[str, ...], default=()

Package names, filesystem paths, or project-relative glob patterns.

spark : bool, default=False

Observe Spark driver actions lazily when Spark methods are used. Require PySpark to be available in the existing environment. Leave PySpark unloaded and its JVM listener dormant until needed.

notebooks : bool, default=True

Snapshot notebook cells and instrument available notebook integrations.

child_notebooks : bool, default=True

Automatically snapshot and profile Databricks child notebooks using temporary workspace copies when SDK access permits it.

display : str | DisplayMode, default=DisplayMode.END

Display a full report at completion (end) or after each cell (cell), compact inline cell results (cell-summary), or only on request (none). Cell summaries do not automatically display a full report at stop.

output : str | None, default=None

Explicit report destination. None opens a temporary HTML report.


See Also

profile

Create a context-managed session using explicit Config options.

Session

Collect one source profiling run and render portable HTML.


Example

>>> from linescope.config import Config

>>> Config(backend="trace").memory
False