def dump_compile(codeobject, filename, timestamp, magic):
    """Write code object as a byte-compiled file

    Arguments:
    codeobject: code object
    filefile: bytecode file to write
    timestamp: timestamp to put in file
    magic: Pyton bytecode magic
    """
    # Atomically write the pyc/pyo file.  Issue #13146.
    # id() is used to generate a pseudo-random filename.
    path_tmp = '%s.%s' % (filename, id(filename))
    fc = None
    try:
        fc = open(path_tmp, 'wb')
        if PYTHON3:
            fc.write(bytes([0, 0, 0, 0]))
        else:
            fc.write('\0\0\0\0')
        wr_long(fc, timestamp)
        marshal.dump(codeobject, fc)
        fc.flush()
        fc.seek(0, 0)
        fc.write(magic)
        fc.close()
        os.rename(path_tmp, filename)
    except OSError:
        try:
            os.unlink(path_tmp)
        except OSError:
            pass
        raise
    finally:
        if fc: fc.close()
def dump_compile ( codeobject , filename , timestamp , magic ) : path_tmp = '%s.%s' % ( filename , id ( filename ) ) fc = None try : fc = open ( path_tmp , 'wb' ) if PYTHON3 : fc . write ( bytes ( [ 0 , 0 , 0 , 0 ] ) ) else : fc . write ( '\0\0\0\0' ) wr_long ( fc , timestamp ) marshal . dump ( codeobject , fc ) fc . flush ( ) fc . seek ( 0 , 0 ) fc . write ( magic ) fc . close ( ) os . rename ( path_tmp , filename ) except OSError : try : os . unlink ( path_tmp ) except OSError : pass raise finally : if fc : fc . close ( )
Write code object as a byte-compiled file

    Arguments:
    codeobject: code object
    filefile: bytecode file to write
    timestamp: timestamp to put in file
    magic: Pyton bytecode magic