[Tex/LaTex] How to set stretch of verbatim to be different than “global” setting

line-spacingverbatim

In my file I need to use 1.5 line stretch. But, as for verbatim I need it to be 1.0. What should I add to preamble to achieve that?

\documentclass{article}
\usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5}
\begin{document} 
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam.
\begin{verbatim}
A = 5
B = 123
C = 123123
\end{verbatim}
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi. Cras vel lorem. Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam.
\end{document} 

Best Answer

I suggest another improvement:

\documentclass{article}
\usepackage[nodisplayskipstretch]{setspace} \setstretch{1.5}

\usepackage{etoolbox}
\preto{\verbatim}{\edef\tempstretch{\baselinestretch}\par\setstretch{1}}
\appto{\endverbatim}{\vspace{-\tempstretch\baselineskip}\vspace{\baselineskip}}

The first \preto does almost the same as David's trick, but it also saves the value of \baselinestretch that we use also at the end of the environment for making the spacing around the verbatim environment symmetric.