i'd like to see a linux system where sched_getaffinity is wrong. it would mean that glibc and kernel are not aligned.
anyway, in a sligthly exotic config, i now get on my laptop
{{{
$ cat /proc/$$/status|grep Cpu
Cpus_allowed:	fff3
Cpus_allowed_list:	0-1,4-15
$ grep processor /proc/cpuinfo |wc -l
4
$ taskset -cp $$
pid 2026's current affinity list: 0,1
$ python -c 'from vsc.utils.affinity import sched_getaffinity; print sum(sched_getaffinity().cpus)'
2
}}}
on linux, with sched_getaffinity, you don't need get_core_count at all. (actually any OS which allows process affinity won't need it; but vsc.utils.affinity only deals with linux)