Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19266
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: while True or while 1 |
| Date | 2012-01-23 15:51 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <jfjvm9$1vc$1@reader1.panix.com> (permalink) |
| References | <4F1AC1D4.2080402@gmail.com> <mailman.4909.1327157944.27778.python-list@python.org> <pL-dnUjq2eH3t4bSnZ2dnUVZ5vudnZ2d@giganews.com> |
On 2012-01-21, Erik Max Francis <max@alcyone.com> wrote:
> Chris Angelico wrote:
>> On Sun, Jan 22, 2012 at 12:47 AM, Andrea Crotti
>> <andrea.crotti.0@gmail.com> wrote:
>>> So I tried to do the following, and the result is surprising. For what
>>> I can see it looks like the interpreter can optimize away the 1 boolean
>>> conversion while it doesn't with the True, the opposite of what I
>>> supposed.
>>>
>>> Anyone can explain me why is that, or maybe is my conclusion wrong?
>>
>> In Python 3, they compile to the same code, because 'True' is a
>> keyword. In Python 2, you can reassign True to be 0.
>
> Why this should concern anyone, I don't know;
I don't think it does concern anybody (except the compiler, who treats
all identifiers the same).
[...]
> The real reason people still use the `while 1` construct, I would
> imagine, is just inertia or habit,
That's certain why I do it. It's left over from the days when C and
Python didn't have symbolic boolean "constants".
> rather than a conscious, defensive decision. If it's the latter,
> it's a case of being _way_ too defensive.
--
Grant Edwards grant.b.edwards Yow! Hmmm ... A hash-singer
at and a cross-eyed guy were
gmail.com SLEEPING on a deserted
island, when ...
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: while True or while 1 Chris Angelico <rosuav@gmail.com> - 2012-01-22 01:59 +1100
Re: while True or while 1 Erik Max Francis <max@alcyone.com> - 2012-01-21 13:13 -0800
Re: while True or while 1 Chris Angelico <rosuav@gmail.com> - 2012-01-22 09:13 +1100
Re: while True or while 1 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-22 05:25 +0000
Re: while True or while 1 Dan Sommers <dan@tombstonezero.net> - 2012-01-22 16:05 +0000
Re: while True or while 1 alex23 <wuwei23@gmail.com> - 2012-01-22 19:55 -0800
Re: while True or while 1 Dave Angel <d@davea.name> - 2012-01-23 08:02 -0500
Re: while True or while 1 Hrvoje Niksic <hniksic@xemacs.org> - 2012-01-23 14:28 +0100
Re: while True or while 1 Dave Angel <d@davea.name> - 2012-01-23 13:33 -0500
Re: while True or while 1 MRAB <python@mrabarnett.plus.com> - 2012-01-22 16:13 +0000
Re: while True or while 1 Grant Edwards <invalid@invalid.invalid> - 2012-01-23 15:51 +0000
Re: while True or while 1 Giampaolo Rodolà <g.rodola@gmail.com> - 2012-01-23 17:41 +0100
Re: while True or while 1 Erik Max Francis <max@alcyone.com> - 2012-01-23 11:12 -0800
Re: while True or while 1 Giampaolo Rodolà <g.rodola@gmail.com> - 2012-01-23 21:20 +0100
Re: while True or while 1 Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-23 10:39 -0700
Re: while True or while 1 Evan Driscoll <edriscoll@wisc.edu> - 2012-01-23 12:05 -0600
Re: while True or while 1 Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-01-23 20:50 +0000
Re: while True or while 1 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-23 14:42 -0800
Re: while True or while 1 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-23 14:42 -0800
Re: while True or while 1 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-24 03:37 +0000
csiph-web