()
return sum(mapping.values()) or None
Return the number of physical cores in the system.
Return the number of physical cores in the system.
Return the number of physical cores in the system .
def cpu_count_physical():
    """Return the number of physical cores in the system."""
    mapping = {}
    current_info = {}
    with open('/proc/cpuinfo', 'rb') as f:
        for line in f:
            line = line.strip().lower()
            if not line:
                # new section
                if (b'physical id' in current_info and
                        b'cpu cores' in current_info):
                    mapping[current_info[b'physical id']] = \
                        current_info[b'cpu cores']
                current_info = {}
            else:
                # ongoing section
                if (line.startswith(b'physical id') or
                        line.startswith(b'cpu cores')):
                    key, value = line.split(b'\t:', 1)
                    current_info[key] = int(value)

    # mimic os.cpu_count()
    return sum(mapping.values()) or None
def cpu_count_physical ( ) : mapping = { } current_info = { } with open ( '/proc/cpuinfo' , 'rb' ) as f : for line in f : line = line . strip ( ) . lower ( ) if not line : # new section if ( b'physical id' in current_info and b'cpu cores' in current_info ) : mapping [ current_info [ b'physical id' ] ] = current_info [ b'cpu cores' ] current_info = { } else : # ongoing section if ( line . startswith ( b'physical id' ) or line . startswith ( b'cpu cores' ) ) : key , value = line . split ( b'\t:' , 1 ) current_info [ key ] = int ( value ) # mimic os.cpu_count() return sum ( mapping . values ( ) ) or None