From 1beb62616b57ebb880f4041fa1d6ad2eae8a657e 2013-07-15 23:26:03 From: MinRK Date: 2013-07-15 23:26:03 Subject: [PATCH] avoid double-iteration over engine IDs in get_dict --- diff --git a/IPython/parallel/client/asyncresult.py b/IPython/parallel/client/asyncresult.py index 557e1c4..0b86b7f 100644 --- a/IPython/parallel/client/asyncresult.py +++ b/IPython/parallel/client/asyncresult.py @@ -195,15 +195,17 @@ class AsyncResult(object): results = [results] engine_ids = [ md['engine_id'] for md in self._metadata ] - seen = set() - for engine_id in engine_ids: - if engine_id in seen: - raise ValueError("Cannot build dict, %i jobs ran on engine #%i"%( - engine_ids.count(engine_id), engine_id)) + + rdict = {} + for engine_id, result in zip(engine_ids, results): + if engine_id in rdict: + raise ValueError("Cannot build dict, %i jobs ran on engine #%i" % ( + engine_ids.count(engine_id), engine_id) + ) else: - seen.add(engine_id) + rdict[engine_id] = result - return dict(zip(engine_ids,results)) + return rdict @property def result(self):