Comment 3 for bug 1094297

Revision history for this message
Lars Butler (lars-butler) wrote :

This patch appears to give a significant performance boost. Running the same test (profile.py), performance improved by a factor of 6.

<patch>
--- a/nhlib/site.py
+++ b/nhlib/site.py
@@ -278,8 +278,8 @@ class SiteCollection(object):
         num_values = data.shape[1]
         result = numpy.empty((total_sites, num_values))
         result.fill(placeholder)
- for i in xrange(num_values):
- result[:, i].put(self.indices, data[:, i])
+ for i, idx in enumerate(self.indices):
+ result[idx] = data[i]
         return result

     def filter(self, mask):
</patch>