How to discover number of *logical* cores on Mac OS X?
You can do this using the sysctl utility:
sysctl -n hw.ncpu
Even easier:
sysctl -n hw.ncpu
This should be cross platform. At least for Linux and Mac OS X.
python -c 'import multiprocessing as mp; print(mp.cpu_count())'
A little bit slow but works.