Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Practical Time Series Analysis

You're reading from   Practical Time Series Analysis Master Time Series Data Processing, Visualization, and Modeling using Python

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781788290227
Length 244 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Avishek Pal Avishek Pal
Author Profile Icon Avishek Pal
Avishek Pal
PKS Prakash PKS Prakash
Author Profile Icon PKS Prakash
PKS Prakash
Arrow right icon
View More author details
Toc

Iterators, iterables, and generators


In Python, we frequently encounter iterators, iterables, and generators as these are efficient ways of looping over a data type or data structure that is a sequence or a sequence can be created out of it. One clear advantage of using these looping techniques is that they require less memory. So, when you must access a sequence element by element, these techniques become very useful because a large sequence does not need to be loaded into memory all at once. For example, if you need to find the square of the first one trillion positive integers, there is no need to create a data structure to hold all numbers in memory at the same time. Iterators, iterables, and generators can be used to generate and process these numbers sequentially. Another example is processing a large text file. The entire file might not fit in memory. Hence, if we need to process the file, for example, to find word count per line of the file, we can iteratively loop over the lines...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime