以下两种方法做同样的事情。就时间/空间复杂度而言,哪一个更有效?
** Method A**
for student in group.students:
for grade in student.grades:
some_operation(grade)
** Method B**
for grade in [grade for student in group.students for grade in student.grades]
some_operation(grade)