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
19 changes: 15 additions & 4 deletions plotly/graph_objs/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def __init__(
if a property in the specification of data, layout, or frames
is invalid AND skip_invalid is False
"""
super().__init__(data, layout, frames, skip_invalid, **kwargs)
# Avoid excess attribute lookup by caching super().__init__
_super_init = super().__init__
_super_init(data, layout, frames, skip_invalid, **kwargs)

def update(self, dict1=None, overwrite=False, **kwargs) -> "Figure":
"""
Expand Down Expand Up @@ -14224,9 +14226,18 @@ def add_scattercarpet(
-------
Figure
"""
from plotly.graph_objs import Scattercarpet

new_trace = Scattercarpet(
# Move the import to class scope to avoid repeated costly import for every function call.
# In hot code paths this reduces import overhead.
# However, for behavioral preservation, must bind only once and not in a shared global.
try:
_Scattercarpet = self.__class__._Scattercarpet
except AttributeError:
from plotly.graph_objs import Scattercarpet as _S

self.__class__._Scattercarpet = _S
_Scattercarpet = _S

new_trace = _Scattercarpet(
a=a,
asrc=asrc,
b=b,
Expand Down