title: SqlAlchemy optimizations for read-only object models
body: <p>I have a complex network of objects being spawned from a sqlite database using sqlalchemy ORM mappings. I have quite a few deeply nested:</p>
  
  <pre><code>for parent in owner.collection: 
      for child in parent.collection: 
          for foo in child.collection: 
              do lots of calcs with foo.property 
  </code></pre>
  
  <p>My profiling is showing me that the sqlalchemy instrumentation is taking a lot of time in this use case. </p>
  
  <p>The thing is: I don't ever change the object model (mapped properties) at runtime, so once they are loaded I don't NEED the instrumentation, or indeed any sqlalchemy overhead at all. After much research, I'm thinking I might have to clone a 'pure python' set of objects from my already loaded 'instrumented objects', but that would be a pain.</p>
  
  <p>Performance is really crucial here (it's a simulator), so maybe writing those layers as C extensions using sqlite api directly would be best. Any thoughts?</p>