Uses dictionary update instead of iterating through keys.

update_universe is a bottleneck on large data sets.

A large portion of that bottleneck is the call to getitem while
looping over the keys, so using update while passing along the internal
__dict__

Seeing about a 40% improvement.
This commit is contained in:
Eddie Hebert
2013-01-06 17:31:03 -05:00
parent dd64bb0fbf
commit 0d841503a7
+1 -2
View File
@@ -241,8 +241,7 @@ class AlgorithmSimulator(object):
self.algo.set_portfolio(event.portfolio)
# Update our knowledge of this event's sid
for field in event.keys():
self.universe[event.sid][field] = event[field]
self.universe[event.sid].update(event.__dict__)
def simulate_snapshot(self, date):
"""