def insert_bytes(fobj, size, offset, BUFFER_SIZE=<NUM_LIT:2>**<NUM_LIT:16>):
assert <NUM_LIT:0> < size<EOL>assert <NUM_LIT:0> <= offset<EOL>locked = False<EOL>fobj.seek(<NUM_LIT:0>, <NUM_LIT:2>)<EOL>filesize = fobj.tell()<EOL>movesize = filesize - offset<EOL>fobj.write(b'<STR_LIT:\x00>' * size)<EOL>fobj.flush()<EOL>try:<EOL><INDENT>try:<EOL><INDENT>import mmap<EOL>file_map = mmap.mmap(fobj.fileno(), filesize + size)<EOL>try:<EOL><INDENT>file_map.move(offset + size, offset, movesize)<EOL><DEDENT>finally:<EOL><INDENT>file_map.close()<EOL><DEDENT><DEDENT>except (ValueError, EnvironmentError, ImportError):<EOL><INDENT>locked = lock(fobj)<EOL>fobj.truncate(filesize)<EOL>fobj.seek(<NUM_LIT:0>, <NUM_LIT:2>)<EOL>padsize = size<EOL>while padsize:<EOL><INDENT>addsize = min(BUFFER_SIZE, padsize)<EOL>fobj.write(b"<STR_LIT:\x00>" * addsize)<EOL>padsize -= addsize<EOL><DEDENT>fobj.seek(filesize, <NUM_LIT:0>)<EOL>while movesize:<EOL><INDENT>thismove = min(BUFFER_SIZE, movesize)<EOL>fobj.seek(-thismove, <NUM_LIT:1>)<EOL>nextpos = fobj.tell()<EOL>data = fobj.read(thismove)<EOL>fobj.seek(-thismove + size, <NUM_LIT:1>)<EOL>fobj.write(data)<EOL>fobj.seek(nextpos)<EOL>movesize -= thismove<EOL><DEDENT>fobj.flush()<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if locked:<EOL><INDENT>unlock(fobj)<EOL><DEDENT><DEDENT>
Insert size bytes of empty space starting at offset.

    fobj must be an open file object, open rb+ or
    equivalent. Mutagen tries to use mmap to resize the file, but
    falls back to a significantly slower method if mmap fails.