def METHOD_NAME(self, data, stream=None, **kw):
    inefficient = False
    if not stream:
        inefficient = True
        stream = StringIO()
    YAML.METHOD_NAME(self, data, stream, **kw)
    if inefficient:
        return stream.getvalue()