Skip to content

Commit 1061b24

Browse files
committed
Pre-compile a regex to improve performance.
1 parent 0f171dd commit 1061b24

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

plotly/graph_objs/graph_objs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
from plotly import exceptions, graph_reference
3535
from plotly.graph_objs import graph_objs_tools
3636

37+
_subplot_regex = re.compile(r'(?P<digits>\d+$)')
38+
3739

3840
class PlotlyBase(object):
3941
"""
@@ -506,7 +508,7 @@ def _get_subplot_attributes(self):
506508

507509
def _get_subplot_key(self, key):
508510
"""Some keys can have appended integers, this handles that."""
509-
match = re.search(r'(?P<digits>\d+$)', key)
511+
match = _subplot_regex.search(key)
510512
if match:
511513
root_key = key[:match.start()]
512514
if (root_key in self._get_subplot_attributes() and

0 commit comments

Comments
 (0)