Performance Advantages to Iterators?

后端 未结 9 1802
梦毁少年i
梦毁少年i 2020-11-28 10:45

What (if any) performance advantages are offered by using iterators. It seems like the \'Right Way\' to solve many problems, but does it create faster/more memory-conscious

9条回答
  •  没有蜡笔的小新
    2020-11-28 11:26

    Iterators are just classes that implement a particular interface, specifically an interface for going to the next one. In Python, lists, tuples, dicts, strings, and files all implement this interface. If they are implemented poorly, it may result in poor performance, but there is nothing inherent to the interface that implies good or bad performance.

提交回复
热议问题