How can one surelly tell that function retuns an iterable object, which calculates results on demand, and not an iterator, which returns already calculated results?
For e.g. function filter()
from python's documentation says:
Construct an iterator from those elements of iterable for which function returns true
Reading that I cat tell that this function returns an object which implements iterable protocol but I can't be sure it won't eat up all my memory if use it with generator which reads values from 16gb file untill I read further and see the Note:
Note that filter(function, iterable) is equivalent to the generator expression (item for item in iterable if function(item))
So, how does one can tell that function calculates returned results on demand and not just iterating over temporary lists which holds already calculated values? I have to inspect sources?