import yaml


def dump(obj, fp, is_safe=True):
    """Converts a Python object as a YAML document to ``fp``.

    :param obj: python object to convert into YAML representation.
    :param fp: a ``.write()``-supporting file-like object
    :param is_safe: Turn off safe dumping.
    """
    yaml_dumper = yaml.Dumper
    if is_safe:
        if hasattr(yaml, 'CSafeDumper'):
            yaml_dumper = yaml.CSafeDumper
        else:
            yaml_dumper = yaml.SafeDumper
    return yaml.dump(obj, fp, default_flow_style=False, Dumper=yaml_dumper)