Help me to optimize this code:
doe = DistanceOnEarth()
def get_mdr_distance(row):
    route_geom = shapely.wkt.loads(row.provider_route)
    route_points = route_geom.coords[:]
    mdr_points = []
    mdr_distance = 0
    for points in split_list(route_points):
        point_1, point_2 = points
        line = shapely.geometry.LineString(points)
        is_mdr = (
            requests.post(
                MDR_URL,
                data=line.wkt,
                headers={"accept": "*/*", "Content-Type": "text/plain"},
            ).content
            == b"true"
        )
        if is_mdr:
            mdr_points.extend(points)
        else:
            if len(mdr_points) > 0:
                mdr_points.extend([point_1])
                mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points))
                mdr_points = []
    if len(mdr_points) > 0:
        mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points))
    return mdr_distance
ช่วยฉันเพิ่มประสิทธิภาพโค้ดนี้: doe = DistanceOnEarth() def get_mdr_distance(row): route_geom = shapely.wkt.loads(row.provider_route) route_points = route_geom.coords[:] mdr_points = [] mdr_distance = 0 สำหรับคะแนนใน split_list( route_points): point_1, point_2 = point line = shapely.geometry.LineString(points) is_mdr = (ร้องขอโพสต์ ( MDR_URL, data=line.wkt, headers={"accept": "*/*", "Content-Type ": "text/plain"}, ).content == b"true" ) if is_mdr: mdr_points.extend(points) else: if len(mdr_points) > 0: mdr_points.extend([point_1]) mdr_distance += doe .get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) mdr_points = [] if len(mdr_points) > 0: mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) กลับ mdr_distance
spam lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor creativity violence