ansible/ansible — pull request #4936 by stoned (2013-11-18 02:59:27+00:00)
Title: Improve Group.get_hosts() performance.

- reduce hosts group list to unique elements faster
- add a cache of already computed hosts group list

As an example I was using a trivial playbook with and inventory of 1122 hosts and 2850 groups: Group.get_hosts()
is called more and 3 000 000 times, accounting for 9 minutes of runtime on my test machine.
With the proposed hosts group list reduction to unique members implementation, execution time drops to about 30s.
And when adding the cache of the computed hosts group list, execution time drops to about 15s.