How can I check nbr of cores of computer?
duncan.booth at invalid.invalid
Thu Jul 31 10:11:33 CEST 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,"%
>>> print howmanycores()
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list