Issue #2065 has been updated by Yusuke Endoh. Status changed from Open to Feedback Hi, > It would be nice if there were a method that iterates ancestors without generating the ancestors array: > > SomeClass.each_ancestor do |ancestor| > # ... > end > > This could improve the performance of DSLs that want to support method-like inheritance. Show a benchmark. I bet it is not bottleneck in your application. It is endless to provide each_* method corresponding to any methods that returns an array. I'll close this ticket unless there is no objection. > As a side note, in my use case I offer caching like you suggest as an option to improve performance. However it's exactly as you point out... hard to invalidate at the right time. Cannot Module#included be used? class Class AncestorsCache = {} def ancestors_cached AncestorsCache[self] ||= ancestors end end class Module def included(x) Class::AncestorsCache.clear end end class C; end p C.ancestors_cached #=> [C, Object, Kernel, BasicObject] module M; end class C; include M; end p C.ancestors_cached #=> [C, M, Object, Kernel, BasicObject] -- Yusuke Endoh <mame / tsg.ne.jp> ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2065 ---------------------------------------- http://redmine.ruby-lang.org