title: Generate .pyc from Python AST?
body: <p>How would I generate a .pyc file from a Python AST such that I could import the file from Python?</p>
  
  <p>I've used <code>compile</code> to create a code object, then written the <code>co_code</code> attribute to a file, but when I try to import the file from Python, I get an <code>ImportError: Bad magic number in output.pyc</code>.</p>