xwe'll see timing techniques later in for measuring the relative speed of alternatives like these version skew notein python xthe iteration method is named next(instead of __next__(for portabilitya next(xbuilt-in function is also available in both python and ( and later)and calls __next__(in and next(in apart from method namesiteration works the same in and in all other ways in and simply use next(or next(xfor manual iterations instead of ' __next__()prior to use next(calls instead of next(xmanual iterationiter and next to simplify manual iteration codepython also provides built-in functionnextthat automatically calls an object' __next__ method per the preceding notethis call also is supported on python for portability given an iterator object xthe call next(xis the same as __next__(on (and next(on )but is noticeably simpler and more version-neutral with filesfor instanceeither form may be usedf open('script py' __next__('import sys\nf __next__('print(sys path)\nf open('script py'next( 'import sys\nnext( 'print(sys path)\ncall iteration method directly the next(fbuilt-in calls __next__(in next( =[ xf __next__()][ xf next()technicallythere is one more piece to the iteration protocol alluded to earlier when the for loop beginsit first obtains an iterator from the iterable object by passing it to the iter built-in functionthe object returned by iter in turn has the required next method the iter function internally runs the __iter__ methodmuch like next and __next__ spoiler alertthe file iterator still appears to be slightly faster than readlines and at least faster than the while loop in both and on tests 've run with this code on , -line file (while is twice as slow on the usual benchmarking caveats apply--this is true only for my pythonsmy computerand my test fileand python complicates such analyses by rewriting / libraries to support unicode text and be less system-dependent covers tools and techniques you can use to time these loop statements on your own iterationsa first look