spacr.qt.laptop_mode

Run well on a small machine without becoming a smaller application.

This is the fallback reached after normal optimisations. It turns down decorative rendering costs instead of removing application features.

Nothing here changes what a run computes. Every setting it touches is about how the application is DRAWN.

It is chosen automatically, it can be overridden either way, and it says what it turned down – a mode that quietly makes the application different is one nobody can debug.

Functions

apply(→ Dict[str, object])

Turn the mode on or off. Returns what was decided and what changed.

describe(→ str)

The whole decision as one block, for the launch log.

measure(→ Dict[str, object])

What the decision is made from, so it can be reported and tested.

override(→ Optional[bool])

What the environment says, or None when it says nothing.

total_memory_gib(→ Optional[float])

Physical memory in GiB, or None when it cannot be read.

usable_cores(→ int)

Cores this process may actually use, not cores the machine has.

wanted(→ Tuple[bool, str])

Whether to run in laptop mode, and the sentence that says why.

what_it_turns_down(→ Tuple[Tuple[str, str], ...])

Each thing the mode changes, and what a user loses by it.

Module Contents

spacr.qt.laptop_mode.apply(on: bool | None = None) → Dict[str, object][source]

Turn the mode on or off. Returns what was decided and what changed.

Parameters:

on – force the answer; None measures the machine.

Returns:

{"on", "why", "changed"} – changed names each thing actually done, so a caller can say what happened rather than claim it.

NOTHING HERE IS PERSISTED. See _NO_BACKDROP for why: this is a decision about one run on one machine, and the user’s stored preference is not this module’s to answer.

spacr.qt.laptop_mode.describe() → str[source]

The whole decision as one block, for the launch log.

spacr.qt.laptop_mode.measure() → Dict[str, object][source]

What the decision is made from, so it can be reported and tested.

spacr.qt.laptop_mode.override() → bool | None[source]

What the environment says, or None when it says nothing.

spacr.qt.laptop_mode.total_memory_gib() → float | None[source]

Physical memory in GiB, or None when it cannot be read.

spacr.qt.laptop_mode.usable_cores() → int[source]

Cores this process may actually use, not cores the machine has.

os.sched_getaffinity where it exists: a container or a scheduler can pin the process to fewer than cpu_count reports, and pinning is exactly the situation this mode is for.

spacr.qt.laptop_mode.wanted(reading: Dict[str, object] | None = None) → Tuple[bool, str][source]

Whether to run in laptop mode, and the sentence that says why.

Returns:

(on, why). The reason is always populated, including when the answer is no – “spaCR decided not to” is a thing a user reports and somebody has to be able to check.

spacr.qt.laptop_mode.what_it_turns_down() → Tuple[Tuple[str, str], ...][source]

Each thing the mode changes, and what a user loses by it.

ONLY DRAWING. Nothing here is read by a pipeline, so a run computes the same answer in either mode – which is the promise that makes an automatic decision acceptable at all.