[Python-checkins] r74152 - python/trunk/Doc/reference/simple_stmts.rst

Benjamin Peterson benjamin at python.org
Wed Jul 22 15:40:52 CEST 2009


2009/7/22 Nick Coghlan <ncoghlan at gmail.com>:
> benjamin.peterson wrote:
>> Author: benjamin.peterson
>> Date: Wed Jul 22 02:03:43 2009
>> New Revision: 74152
>>
>> Log:
>> simplify
>>
>> Modified:
>>    python/trunk/Doc/reference/simple_stmts.rst
>>
>> Modified: python/trunk/Doc/reference/simple_stmts.rst
>> ==============================================================================
>> --- python/trunk/Doc/reference/simple_stmts.rst       (original)
>> +++ python/trunk/Doc/reference/simple_stmts.rst       Wed Jul 22 02:03:43 2009
>> @@ -282,13 +282,13 @@
>>
>>  The simple form, ``assert expression``, is equivalent to ::
>>
>> -   if __debug__:
>> -      if not expression: raise AssertionError
>> +   if __debug__ and not expression:
>> +       raise AssertionError
>>
>>  The extended form, ``assert expression1, expression2``, is equivalent to ::
>>
>> -   if __debug__:
>> -      if not expression1: raise AssertionError(expression2)
>> +   if __debug__ and not expression1:
>> +       raise AssertionError(expression2)
>
> This change is incorrect as the compiler only optimises away statements
> specifically of the form "if __debug__:". As soon as you put anything
> else in the expression, the compiler no longer detects it as a candidate
> for elimination.

Yeah, but whether it's optimized out in the form is an implementation detail.



-- 
Regards,
Benjamin


More information about the Python-checkins mailing list