title: exec statement with/without prior compile
body: <p>These weekend I've been tearing down to pieces Michele Simionato's <a href="http://pypi.python.org/pypi/decorator/3.0.1" rel="nofollow noreferrer">decorator module</a>, that builds signature-preserving decorators. At the heart of it all there is a dynamically generated function, which works something similar to this...</p>
  
  <pre><code>src = """def function(a,b,c) :\n    return _caller_(a,b,c)\n"""
  evaldict = {'_caller_' : _caller_}
  code = compile(src, '&lt;string&gt;', 'single')
  exec code in evaldict
  new_func = evaldict[function]
  </code></pre>
  
  <p>I have found, fooling around with this code, that the compile step can be completely avoided and go for a single:</p>
  
  <pre><code>exec src in evaldict
  </code></pre>
  
  <p>Now, I'm sure there is a good reason for that additional step, but I haven't been able to find what the difference between both approaches is. Performance?</p>
  
  <p>And since I'm asking, could something similar, i.e. define a new function and get a handle to it, be achieved with eval? I tried, but couldn't get that to work...</p>