Skip to content

Commit

Permalink
Pre-compile a regex to improve performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
theengineear committed Jan 31, 2017
1 parent 0f171dd commit 1061b24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plotly/graph_objs/graph_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from plotly import exceptions, graph_reference
from plotly.graph_objs import graph_objs_tools

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


class PlotlyBase(object):
"""
Expand Down Expand Up @@ -506,7 +508,7 @@ def _get_subplot_attributes(self):

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

0 comments on commit 1061b24

Please sign in to comment.