[PEAK] peak.security weirdness

Phillip J. Eby pje at telecommunity.com
Fri Jan 20 14:11:12 EST 2006


At 07:50 PM 01/20/2006 +0100, Simon Belak wrote:
>Phillip J. Eby wrote:
>>It would be more precise to say that every subexpression is evaluated 
>>immediately unless it depends on the value of a function argument.  All 
>>other subexpressions are constant-folded away, except for zero-argument 
>>function calls, which are assumed to be getters for some dynamic state.
>>All expressions defined by any rule are computed at most once per dispatch.
>
>So, in a rule such as:
>
>   isinstnace(foo, int) and bar() and baz()
>
>baz() and bar() would be immediately evaluated and resulting values 
>constant-folded, reducing the rule to
>
>   isinstnace(foo, int) and [some_constant]

No.  Zero-argument calls to constants are not optimized away, on the 
assumption that they are dynamic getters that should be evaluated every 
time the generic function is called.  So the rule is optimized to:

     isinstance(foo,int) and constant1() and constant2

Or more precisely, it's optimized to a Signature object with three 
expressions, something like:

     foo->ClassTest(int), constant1()->TruthTest(True), 
constant2()->TruthTest(True)

And all this assumes that bar and baz aren't argument names.  :)




More information about the PEAK mailing list