Exporting UV coordinates by face elements
I found the .obj export source in /usr/share/blender It's probably different on your computer, the best place to see where you can find it is to go into user preference under Addons. It seems like the official exporter just creates a hash map of uv coordinates. This seems to be where the magic happens.

# Make our own list so it can be sorted to reduce context switching
    face_index_pairs = [(face, index) for index, face in enumerate(me.polygons)]
        uv = f_index = uv_index = uv_key = uv_val = uv_ls = None

        uv_face_mapping = [None] * len(face_index_pairs)

        uv_dict = {}
        uv_get = uv_dict.get
        for f, f_index in face_index_pairs:
            uv_ls = uv_face_mapping[f_index] = []
            for uv_index, l_index in enumerate(f.loop_indices):
                uv = uv_layer[l_index].uv
                uv_key = veckey2d(uv)
                uv_val = uv_get(uv_key)
                if uv_val is None:
                    uv_val = uv_dict[uv_key] = uv_unique_count
                    fw('vt %.6f %.6f\n' % uv[:])
                    uv_unique_count += 1
                uv_ls.append(uv_val)


Since I answered my own question, should this be deleted? I feel like this has some value to other people who may want to do something similar, as this is a specific and non-trivial task.