import tempfile
import pickle


def _dump(partition):
    """
    Dump the given partition to an external source.

    The default implementation is to pickle the list of objects to a temporary file.

    :param partition: The partition of objects to dump.

    :return: Unique id which can be used to reload the serialized partition. In the case of the
             default implementation this is the path to the temporary file.
    """
    with tempfile.NamedTemporaryFile(delete=False) as fileobj:
        for item in partition:
            pickle.dump(item, fileobj)
        return fileobj.name