How can I check nbr of cores of computer?
Duncan Booth
duncan.booth at invalid.invalid
Thu Jul 31 04:11:33 EDT 2008
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> 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.
>
One way on windows:
>>> import win32pdhutil
>>> def howmanycores():
for i in range(9999):
try: win32pdhutil.GetPerformanceAttributes("Processor(%d)" % i,"%
Processor Time")
except: break
return i
>>> print howmanycores()
2
--
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list
mailing list