The first approach I tried (with a decorated class caching all of a person's languages) didn't work because there's no way to make a decorated object's identity be the same as its non-decorated counterpart. That means we can't really mix them together, specially when we use them in a set().
My second approach makes Person.languages a cachedproperty, and changes .answer_contacts to pre-fill that cache for all answer contacts, thus issuing a single query.
The first approach I tried (with a decorated class caching all of a person's languages) didn't work because there's no way to make a decorated object's identity be the same as its non-decorated counterpart. That means we can't really mix them together, specially when we use them in a set().
My second approach makes Person.languages a cachedproperty, and changes .answer_contacts to pre-fill that cache for all answer contacts, thus issuing a single query.