def parse(self, s, dpi = <NUM_LIT>, prop = None):
if prop is None:<EOL><INDENT>prop = FontProperties()<EOL><DEDENT>cacheKey = (s, dpi, hash(prop))<EOL>result = self._cache.get(cacheKey)<EOL>if result is not None:<EOL><INDENT>return result<EOL><DEDENT>if self._output == '<STR_LIT>' and rcParams['<STR_LIT>']:<EOL><INDENT>font_output = StandardPsFonts(prop)<EOL><DEDENT>else:<EOL><INDENT>backend = self._backend_mapping[self._output]()<EOL>fontset = rcParams['<STR_LIT>']<EOL>fontset_class = self._font_type_mapping.get(fontset.lower())<EOL>if fontset_class is not None:<EOL><INDENT>font_output = fontset_class(prop, backend)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>fontsize = prop.get_size_in_points()<EOL>if self._parser is None:<EOL><INDENT>self.__class__._parser = Parser()<EOL><DEDENT>box = self._parser.parse(s, font_output, fontsize, dpi)<EOL>font_output.set_canvas_size(box.width, box.height, box.depth)<EOL>result = font_output.get_results(box)<EOL>self._cache[cacheKey] = result<EOL>self._parser.clear()<EOL>font_output.destroy()<EOL>font_output.mathtext_backend.fonts_object = None<EOL>font_output.mathtext_backend = None<EOL>return result<EOL>
Parse the given math expression *s* at the given *dpi*.  If
*prop* is provided, it is a
:class:`~matplotlib.font_manager.FontProperties` object
specifying the "default" font to use in the math expression,
used for all non-math text.

The results are cached, so multiple calls to :meth:`parse`
with the same expression should be fast.