fusionbox/django-widgy — pull request #66 by gavinwahl (2013-06-08 00:19:53+00:00)
Title: Optimize

- ContentList -- an optimizing wrapper around a list of Contents

Many operations return a list of Content instances, fetched from a Node queryset. Many common operations on this list only need information in the Node, so it's wasteful to always fetch the Contents.

The optimizations it performs:

- Prefetches the Content instances in bulk (This was already done since 6549cf3f8)
- Implements ``__contains__`` without fetching Contents at all
- Implements ``__len__`` without fetching Contents at all
- Can calculate Content _classes_ with fetching the Content instances

It behaves exactly like a list, so this is backwards compatible. It does have a new public property -- `content_classes` -- which is used to retrieve a list of Content classes when full instances aren't required, such as when you're only doing an `isinstance` check.

- Override treebeard's `is_root` with one that never does a query

Possibly more to come -- I'm working on reducing the number of of times the reverse node relationship (Content.node) query happens.