Simple question,
I want to determine the number of performance cores in an Python script (better a Python app frozen with PyInstaller
, which could make 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 later 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? Maybe using the pyobjc
package?