Here comes another alternative.
The tcblisting
environment saves the content into a file which is read afterwards as a listings or as a compiled text or both. This process can be decoupled:
This gives:
\documentclass{beamer}
\usepackage[listings]{tcolorbox}
\begin{document}
\begin{tcboutputlisting}
\begin{frame}{equation}
$a = b$
\end{frame}
\end{tcboutputlisting}
\begin{frame}[fragile]{Example}
\tcbinputlisting{listing only}
\end{frame}
\end{document}

Just for fun, I add some madness. Since the content of the listing is a code for a beamer frame, we may like to add the compiled frame inside the outer frame ...
This can be done using the compile options of tcolorbox
which do system calls. The intermediate file has to be unique for this. In the decoupled situation here, the option compilable listing
cannot be used and one has to take care of the file name directly. That's the reason for
\tcbset{listing file=\jobname-listing-myslide}
in the following code:
\documentclass{beamer}
\usepackage[listings,raster,skins]{tcolorbox}
\begin{document}
\tcbset{listing file=\jobname-listing-myslide}% <-- Use a unique name
\begin{tcboutputlisting}
\documentclass{beamer}
\begin{document}
\begin{frame}{equation}
$a = b$
\end{frame}
\end{document}
\end{tcboutputlisting}
\begin{frame}[fragile]{Example}
\tcbinputlisting{
listing and comment,pdf comment,run pdflatex,% <-- These options do the trick
% the rest is just to be colorful and nice:
enhanced,oversize,
lower separated=false,
colframe=red!50!black,colback=yellow!10!white,
interior style={top color=yellow!5!white,bottom color=yellow!20!white},
listing options={style=tcblatex,texcsstyle=*\color{red!70!black}},
comment style={drop lifted shadow},
sidebyside,sidebyside gap=1mm,raster columns=1
}
\end{frame}
\tcbset{listing file=\jobname.listing}% <-- reset to default
\end{document}
The output is:
