Cross platform way of finding number of processors on a machine?

Tim Golden mail at timgolden.me.uk
Fri Oct 5 03:58:16 EDT 2007


Nicholas Bastin wrote:
> On 10/4/07, John <weekender_ny at yahoo.com> wrote:
>> Is there a way to find the number of processors on a machine (on linux/
>> windows/macos/cygwin) using python code (using the same code/cross
>> platform code)?
> 
> There's no single call that will give you the same info on every
> platform, but you can obviously write this yourself and switch based
> on os.uname()[0] in most cases.

Second that point about not getting one cross-platform
answer. Under Windows, WMI is often the way to go for
these things:

   http://msdn2.microsoft.com/en-us/library/aa394373.aspx

but, as Nicholas noted:

   """
   Windows Server 2003, Windows XP, and Windows 2000:
     This property is not available.
   """

since it's presumably not available in anything earlier either,
that leaves you with Vista or the early-adopter editions of the
next Windows Server product.

TJG



More information about the Python-list mailing list