How can I check nbr of cores of computer?

Steven D'Aprano steve at
Thu Jul 31 04:39:41 CEST 2008

On Wed, 30 Jul 2008 11:22:12 -0700, John Nagle wrote:

> defn noob wrote:
>> How can I check how many cores my computer has? Is it possible to do
>> this in a Python-app?
>      Why do you care?  Python can't use more than one of them at
> a time anyway.

Why do you care why he cares? And he didn't ask how to *use* multiple 
cores, but how to detect if they're there.

Maybe all he wants is to write a toy program that outputs "Hello Fred, 
your computer has N cores in the CPU. Have a nice day!".

I don't expect that Python will have a built-in core-counting function. 
You would probably need to ask the operating system. On Linux, you could 
do this:

import os
text = os.popen('cat /proc/cpuinfo').read()

How you would do it in Windows or Mac, I have no idea.


More information about the Python-list mailing list