什么时候使用 zip 而不是 izip 更好? [英] When is it better to use zip instead of izip?
本文介绍了什么时候使用 zip 而不是 izip 更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么时候使用 zip
而不是 更好a href="https://docs.python.org/2/library/itertools.html#itertools.izip">itertools.izip
?
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屋!
查看全文