Getting processor information in Python

后端 未结 10 1964
一向
一向 2020-11-29 04:20

Using Python is there any way to find out the processor information... (I need the name)

I need the name of the processor that the interpreter is running on. I check

10条回答
  •  粉色の甜心
    2020-11-29 05:07

    There's some code here:

    https://github.com/pydata/numexpr/blob/master/numexpr/cpuinfo.py

    its very OS-dependent, so there's lots of if-branches. But it does work out all the CPU capabilities.

    $ python cpuinfo.py 
    CPU information: getNCPUs=2 has_mmx has_sse has_sse2 is_64bit is_Intel is_Pentium is_PentiumIV
    

    For linux it looks in /proc/cpuinfo and tries using uname. For Windows it looks like it uses the registry.

    To get the [first] processor name using this module:

    >>> import cpuinfo
    >>> cpuinfo.cpu.info[0]['model name']
    'Intel(R) Pentium(R) 4 CPU 3.60GHz'
    

    If its got more than one processor, then the elements of cpuinfo.cpu.info will have their names. I don't think I've ever seen a PC with two different processors though (not since the 80's when you could get a Z80 co-processor for your 6502 CPU BBC Micro...)

提交回复
热议问题