def _create_affinity_mask(mask_or_list):
    """converts a list of cores to a mask if necessary"""
    if isinstance(mask_or_list, int):
        return mask_or_list
    cores = mask_or_list
    mask = 0
    for core in cores:
        mask |= 1 << core
    return mask
