Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion plotly/graph_objs/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21976,6 +21976,15 @@ def select_mapboxes(self, selector=None, row=None, col=None):
objects that satisfy all of the specified selection criteria
"""

# Optimize by avoiding Python's generic machinery for this common case
# of "select all mapbox objects" with no selector and no row/col filtering.
if selector is None and row is None and col is None:
layout = self.layout
mapbox_keys = [
k for k in layout if k.startswith("mapbox") and layout[k] is not None
]
# Prefer generator expression for memory efficiency (instead of list -> generator)
return (layout[k] for k in mapbox_keys)
return self._select_layout_subplots_by_prefix("mapbox", selector, row, col)

def for_each_mapbox(self, fn, selector=None, row=None, col=None) -> "Figure":
Expand Down Expand Up @@ -22009,7 +22018,6 @@ def for_each_mapbox(self, fn, selector=None, row=None, col=None) -> "Figure":
"""
for obj in self.select_mapboxes(selector=selector, row=row, col=col):
fn(obj)

return self

def update_mapboxes(
Expand Down