The "loop and a half"
Robin Becker
robin at reportlab.com
Wed Oct 4 05:01:07 EDT 2017
Given the prevalence of the loop and a half idea in python I wonder why we don't
have a "do" or "loop" statement to start loops without a test.
> C:\Python27\Lib>grep "while True" *.py | wc -l
> 99
>
> C:\Python27\Lib>grep "while 1" *.py | wc -l
> 117
> C:\Python36\Lib>grep "while True" *.py | wc -l
> 131
>
> C:\Python36\Lib>grep "while 1" *.py | wc -l
> 44
How much does the while True actually cost compared to nothing?
--
Robin Becker
More information about the Python-list
mailing list