Looping [was Re: Python and the need for speed]
marko at pacujo.net
Mon Apr 17 14:38:05 EDT 2017
Ben Bacarisse <ben.usenet at bsb.me.uk>:
> Marko Rauhamaa <marko at pacujo.net> writes:
>> What I notice in my numbers is that about one half of my while loops
>> are "while True", and about a third of my loops are while loops.
> I fo[u]nd the proportion on while True: loops surprising. Is there
> something about Python that encourages that kind of loop?
Here's a typical example of such a loop in Python (ver 2):
snippet = os.read(rdfd, 1000)
except OSError as e:
if e.errno == errno.EAGAIN:
if not snippet:
I find myself writing similar loops in C a lot, as well.
More information about the Python-list