[Python] How to get the number of threads per cores in python

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    My computers CPU has 4 cores and 2 threads for each core, as I can get it by lscpu command:

    Architecture: x86_64
    CPU op-mode(s): 32-bit, 64-bit
    Byte Order: Little Endian
    Address sizes: 48 bits physical, 48 bits virtual
    CPU(s): 4
    On-line CPU(s) list: 0-3
    Thread(s) per core: 2
    ...


    I can get the numbers of cores by multiprocessing.cpu_count() python standard. But I can't find any way to get the number of threads per core by python. I know I can execute lscpu command and get the number of threads by parsing the output in python. But is there any standard solution?

    Continue reading...

Compartilhe esta Página