Performance bottleneck graph objects e.g., go.Scatter

We have some rectangle drawing routines that have a bottleneck in go.Scatter creation (plotly 5.10). Basically, we have something along these lines:

# fig has been set up already
rects = generate_rects(...)
for r in rects:
  scatter = go.Scatter(x=r.x, y=r.y, fill="toself", mode="lines", ...)
  fig.add_trace(scatter)

Profiling shows that the go.Scatter call is taking a significant portion of time as we are sometimes generating a lot of rectangles. We tried recoding this as:

# fig has been set up already
rects = generate_rects(...)
dummy_scatter =  go.Scatter(x=[0, 1, 2, 3] y=[0, 1, 2, 3], fill="toself", mode="lines", ...)
for r in rects:
   scatter = go.Scatter(dummy_scatter)
   scatter['x'] = r.x
   scatter['y'] = r.y
   fig.add_trace(scatter)

This does not work and an empty plot is rendered. Is there something special about construction and setting the x/y when lines and toself are involved? Am I barking up the wrong tree and is there a better way to minimize the go.Scatter overhead?

Thanks - Marie