tomchristie/django-rest-framework — pull request #433 by irrelative (2012-11-20 06:15:05+00:00)
Title: Cache default_fields per serializer instance for faster serialization

Hello,

While using the very nice django rest framework to serialize several thousands objects, we noticed some slower performance than our previous serialization methods. Profiling this code showed that more time was being spent creating default fields than should be the case -- that method was being run for each model instance, when it only needed to run per serializer instance.

Investigating the code further found comments that inspired this change. Serializing about 2000 objects was taking around 1.5 seconds -- with this change, take less than 0.5 seconds.

Best,
Justin