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
This patch appears to give a significant performance boost. Running the same test (profile.py), performance improved by a factor of 6.
<patch> object) : (total_ sites, num_values))
result. fill(placeholde r) self.indices, data[:, i]) self.indices) :
--- a/nhlib/site.py
+++ b/nhlib/site.py
@@ -278,8 +278,8 @@ class SiteCollection(
num_values = data.shape[1]
result = numpy.empty(
- for i in xrange(num_values):
- result[:, i].put(
+ for i, idx in enumerate(
+ result[idx] = data[i]
return result
def filter(self, mask):
</patch>