Comment

AGMMGA

----
How multiprocessing figures this out I don't know but I can't imagine it being anything but a standard lib OS call to ask the operating system how many CPUs it has.
----

There exists a cpu_count() function. Useful if you want to limit yourself to say, 25% of available cores. I guess it simply calls nprocs on unix.

>>>from multiprocessing import cpu_count
>>>cpu_count() #same as nproc
32

From the docs: (https://docs.python.org/2/library/multiprocessing.html)
multiprocessing.cpu_count()
    Return the number of CPUs in the system. May raise NotImplementedError.

so I guess a try..except is in order if you want to use this yourself. Not sure when the NotImplemented triggers, maybe it's a OS-dependent thing.