def parse_memory_value(s):
    number, unit = split_number_and_unit(s)
    if not unit or unit == 'B':
        return number
    elif unit == 'kB':
        return number * _BYTE_FACTOR
    elif unit == 'MB':
        return number * _BYTE_FACTOR * _BYTE_FACTOR
    elif unit == 'GB':
        return number * _BYTE_FACTOR * _BYTE_FACTOR * _BYTE_FACTOR
    elif unit == 'TB':
        return number * _BYTE_FACTOR * _BYTE_FACTOR * _BYTE_FACTOR * _BYTE_FACTOR
    else:
        raise ValueError('unknown unit: {} (allowed are B, kB, MB, GB, and TB)'.format(unit))
Parse a string that contains a number of bytes, optionally with a unit like MB.
dataset/ETHPy150Open sosy-lab/benchexec/benchexec/util.py/parse_memory_value