Looping [was Re: Python and the need for speed]

Grant Edwards grant.b.edwards at gmail.com
Mon Apr 17 15:15:08 EDT 2017

On 2017-04-17, Ben Bacarisse <ben.usenet at bsb.me.uk> wrote:
> Marko Rauhamaa <marko at pacujo.net> writes:
>> Terry Reedy <tjreedy at udel.edu>:
>>> On 4/17/2017 3:11 AM, Marko Rauhamaa wrote:
>>>> Here's statistics from a medium-sized project of mine:
>>>>    while True:            34
>>>>    while <condition>:     39
>>>>    for ... in ...:       158
>>> As I posted previously, the ratio of for-loops in the stdlib is about 7
>>> to 1.
>> 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 fond the proportion on while True: loops surprising.  Is there
> something about Python that encourages that kind of loop?

That's how you read data from a socket/pipe/file.

Grant Edwards               grant.b.edwards        Yow! Your CHEEKS sit like
                                  at               twin NECTARINES above
                              gmail.com            a MOUTH that knows no
                                                   BOUNDS --

More information about the Python-list mailing list