提交 3db224ef authored 作者: Olivier Delalleau's avatar Olivier Delalleau

zip -> izip

上级 a73afb69
...@@ -6,6 +6,7 @@ Defines Linkers that deal with C implementations. ...@@ -6,6 +6,7 @@ Defines Linkers that deal with C implementations.
from copy import copy from copy import copy
import re #for set_compiledir import re #for set_compiledir
import os, sys, StringIO import os, sys, StringIO
from itertools import izip
if sys.version_info[:2] >= (2,5): if sys.version_info[:2] >= (2,5):
...@@ -733,8 +734,8 @@ class CLinker(link.Linker): ...@@ -733,8 +734,8 @@ class CLinker(link.Linker):
output_storage, output_storage,
keep_lock=keep_lock) keep_lock=keep_lock)
return thunk, \ return thunk, \
[link.Container(input, storage) for input, storage in zip(self.env.inputs, input_storage)], \ [link.Container(input, storage) for input, storage in izip(self.env.inputs, input_storage)], \
[link.Container(output, storage, True) for output, storage in zip(self.env.outputs, output_storage)], \ [link.Container(output, storage, True) for output, storage in izip(self.env.outputs, output_storage)], \
error_storage error_storage
def get_init_tasks(self): def get_init_tasks(self):
...@@ -1302,8 +1303,8 @@ class OpWiseCLinker(link.LocalLinker): ...@@ -1302,8 +1303,8 @@ class OpWiseCLinker(link.LocalLinker):
release_lock() release_lock()
assert get_lock.n_lock == orig_n_lock assert get_lock.n_lock == orig_n_lock
return f, [link.Container(input, storage) for input, storage in zip(env.inputs, input_storage)], \ return f, [link.Container(input, storage) for input, storage in izip(env.inputs, input_storage)], \
[link.Container(output, storage, True) for output, storage in zip(env.outputs, output_storage)], \ [link.Container(output, storage, True) for output, storage in izip(env.outputs, output_storage)], \
thunks, order thunks, order
...@@ -1372,21 +1373,21 @@ class DualLinker(link.Linker): ...@@ -1372,21 +1373,21 @@ class DualLinker(link.Linker):
_f, i2, o2, thunks2, order2 = OpWiseCLinker().accept(env, no_recycling = no_recycling).make_all(**kwargs) _f, i2, o2, thunks2, order2 = OpWiseCLinker().accept(env, no_recycling = no_recycling).make_all(**kwargs)
def f(): def f():
for input1, input2 in zip(i1, i2): for input1, input2 in izip(i1, i2):
# set the inputs to be the same in both branches # set the inputs to be the same in both branches
# the copy is necessary in order for inplace ops not to interfere # the copy is necessary in order for inplace ops not to interfere
input2.storage[0] = copy(input1.storage[0]) input2.storage[0] = copy(input1.storage[0])
for thunk1, thunk2, node1, node2 in zip(thunks1, thunks2, order1, order2): for thunk1, thunk2, node1, node2 in izip(thunks1, thunks2, order1, order2):
for output, storage in zip(node1.outputs, thunk1.outputs): for output, storage in izip(node1.outputs, thunk1.outputs):
if output in no_recycling: if output in no_recycling:
storage[0] = None storage[0] = None
for output, storage in zip(node2.outputs, thunk2.outputs): for output, storage in izip(node2.outputs, thunk2.outputs):
if output in no_recycling: if output in no_recycling:
storage[0] = None storage[0] = None
try: try:
thunk1() thunk1()
thunk2() thunk2()
for output1, output2 in zip(thunk1.outputs, thunk2.outputs): for output1, output2 in izip(thunk1.outputs, thunk2.outputs):
self.checker(output1, output2) self.checker(output1, output2)
except Exception: except Exception:
link.raise_with_op(node1) link.raise_with_op(node1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论