什么时候使用zip而不是izip更好? [英] When is it better to use zip instead of izip?
本文介绍了什么时候使用zip而不是izip更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么时候使用 zip
而不是
When is it better to use zip
instead of itertools.izip
?
推荐答案
当您知道要构建的项的完整列表时(例如,传递给可以就地修改该列表的函数).或者,当您想强制要传递给zip()
的参数时,在该特定点进行完全评估.
When you know you'll want the full list of items constructed (for instance, for passing to a function that would modify that list in-place). Or when you want to force the arguments you're passing to zip()
to be completely evaluated at that specific point.
这篇关于什么时候使用zip而不是izip更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文