I want to determine the number of performance cores in a Python script (it's actually going to be a Python app frozen with PyInstaller, if that makes a difference).
There are some ways to get the number of CPUs/cores like os.cpu_count()
, multiprocessing.cpu_count()
or psutil.cpu_count()
(the latter allowing discrimination between physical and virtual cores). However, Apple Silicon CPUs are separated into performance and efficiency cores, which you can get with (e.g.) sysctl hw.perflevel0.logicalcpu_max
for performance and sysctl hw.perflevel1.logicalcpu_max
for efficiency cores.
Is there any way to get this in Python besides running sysctl
and get the shell output?