title: Why is accessing a namedtuple by field name slower than accessing a class's member variable?
body: <p>We were doing some experiments to compare the access time in classes and named tuples and observed something strange.</p>
  
  <pre><code>import time
  from collections import namedtuple as namedtuple
  
  class myclass(object):
  
    def __init__(self, _name, _dob, _value):
      self.name = _name
      self.dob = _dob
      self.value = _value
  
  randomperson1 = myclass( 'randomperson', 10102000, 10.45 )
  
  person = namedtuple( 'person', 'name dob value' )
  randomperson2 = person( 'randomperson', 10102000, 10.45) 
  </code></pre>
  
  <p>While using timeit of ipython, the following was observed:</p>
  
  <pre><code>%timeit randomperson1.name,randomperson1.value,randomperson1.dob
  10000000 loops, best of 3: 125 ns per loop
  
  %timeit randomperson2.name,randomperson2.value,randomperson2.dob
  1000000 loops, best of 3: 320 ns per loop
  
  %timeit randomperson2[0],randomperson2[1],randomperson2[2]
  10000000 loops, best of 3: 127 ns per loop
  </code></pre>
  
  <p>Why's accessing a namedtuple by field name so much slower than accessing a class's member variable? Is there any way to speed this up?</p>