Cpu
provide.foundation.platform.cpu
¶
TODO: Add module docstring.
Functions¶
get_cpu_brand
¶
Get CPU brand string.
Returns:
| Type | Description |
|---|---|
str
|
CPU brand string (e.g., "Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz") |
Example
from provide.foundation.platform import get_cpu_brand get_cpu_brand() 'Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz'
Source code in provide/foundation/platform/cpu.py
get_cpu_count
¶
Get number of logical CPUs.
Returns:
| Type | Description |
|---|---|
int | None
|
Number of logical CPUs, or None if not available |
Example
from provide.foundation.platform import get_cpu_count get_cpu_count() 8
Source code in provide/foundation/platform/cpu.py
get_cpu_flags
¶
Get list of CPU flags/features.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of CPU flags (e.g., ["sse", "avx", "avx2"]), or empty list if not available |
Example
from provide.foundation.platform import get_cpu_flags flags = get_cpu_flags() 'avx2' in flags True
Source code in provide/foundation/platform/cpu.py
get_cpu_info
¶
Get detailed CPU information.
Returns comprehensive CPU information including brand, vendor, architecture, flags, and feature support.
Returns:
| Type | Description |
|---|---|
dict[str, str | int | list[str] | None]
|
Dictionary containing CPU information. Keys include: |
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
|
dict[str, str | int | list[str] | None]
|
When py-cpuinfo is not available, returns basic information from |
dict[str, str | int | list[str] | None]
|
platform module. |
Example
from provide.foundation.platform import get_cpu_info info = get_cpu_info() info['brand'] 'Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz' 'avx2' in info.get('flags', []) True
Source code in provide/foundation/platform/cpu.py
has_cpu_flag
¶
Check if CPU has a specific flag/feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flag
|
str
|
Flag name to check (e.g., "avx2", "sse4_2") |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if CPU has the flag, False otherwise |
Example
from provide.foundation.platform import has_cpu_flag has_cpu_flag('avx2') True has_cpu_flag('avx512f') False