title: __iter__() implemented as a generator
body: <p>I have an object subclass which implements a dynamic dispatch <code>__ iter __</code> using a caching generator (I also have a method for invalidating the iter cache) like so:</p>
  
  <pre><code>def __iter__(self):
      print("iter called")
      if self.__iter_cache is None:
          iter_seen = {}
          iter_cache = []
          for name in self.__slots:
              value = self.__slots[name]
              iter_seen[name] = True
              item = (name, value)
              iter_cache.append(item)
              yield item           
          for d in self.__dc_list:
              for name, value in iter(d):
                  if name not in iter_seen:
                      iter_seen[name] = True
                      item = (name, value)
                      iter_cache.append(item)
                      yield item
          self.__iter_cache = iter_cache
      else:
          print("iter cache hit")
          for item in self.__iter_cache:
              yield item
  </code></pre>
  
  <p>It seems to be working... Are there any gotchas I may not be aware of? Am I doing something ridiculous?</p>