def bytes2iec(size, compact=False):
postfn = lambda text: text.replace('<STR_LIT:U+0020>', '<STR_LIT>') if compact else text<EOL>if size < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>".format(size))<EOL><DEDENT>if size < <NUM_LIT>:<EOL><INDENT>return postfn('<STR_LIT>'.format(size))<EOL><DEDENT>scaled = size<EOL>for iec_unit in IEC_UNITS[<NUM_LIT:1>:]:<EOL><INDENT>scaled /= <NUM_LIT><EOL>if scaled < <NUM_LIT>:<EOL><INDENT>return postfn('<STR_LIT>'.format(scaled, iec_unit))<EOL><DEDENT><DEDENT>raise ValueError("<STR_LIT>".format(size))<EOL>
Convert a size value in bytes to its equivalent in IEC notation.

        See `<http://physics.nist.gov/cuu/Units/binary.html>`_.

        Parameters:
            size (int): Number of bytes.
            compact (bool): If ``True``, the result contains no spaces.

        Return:
            String representation of ``size``.

        Raises:
            ValueError: Negative or out of bounds value for ``size``.