def compute_efficiency_gap(partition):
    """
    Input is a gerrychain.Partition object 
    with voteshare and population data. 

    It is assumed that `add_population_data` and 
    `add_voteshare_data` have been called on 
    the given partition's GeoDataFrame. 

    Returns the efficiency gap of 
    the districting plan from the GOP perspective:
    (gop_wasted_votes - dem_wasted_votes) / total_votes.

    Reference: Stephanopoulos and McGhee. 
    "Partisan gerrymandering and the efficiency gap." 2015.
    """
    k = len(partition.parts)
    gop_wasted_votes = 0
    dem_wasted_votes = 0

    for i in range(1, k + 1):
        gop_votes = partition['gop_votes'][i]
        dem_votes = partition['dem_votes'][i]
        if gop_votes > dem_votes:
            gop_wasted_votes += gop_votes - 0.5 * (gop_votes + dem_votes)
            dem_wasted_votes += dem_votes
        else:
            gop_wasted_votes += gop_votes
            dem_wasted_votes += dem_votes - 0.5 * (gop_votes + dem_votes)

    # Using total population as a proxy for total_votes for simplicity
    total_votes = partition.graph.data.population.sum()
    return (gop_wasted_votes - dem_wasted_votes) / total_votes