PERF: Remove in operator from inner loop.

Ask forgiveness via exception handling instead.
This commit is contained in:
fawce
2013-11-12 21:24:30 -05:00
committed by Eddie Hebert
parent f8755a5602
commit f33193069c
+4 -2
View File
@@ -217,8 +217,10 @@ class AlgorithmSimulator(object):
Update the universe with new event information.
"""
# Update our knowledge of this event's sid
if event.sid in self.current_data:
# rather than use if event.sid in ..., just trying
# and handling the exception is significantly faster
try:
sid_data = self.current_data[event.sid]
else:
except KeyError:
sid_data = self.current_data[event.sid] = SIDData()
sid_data.__dict__.update(event.__dict__)