Re: [Python-Dev] Temporary Constantification

2006-06-25 Thread Guido van Rossum
On 6/25/06, Eric Sumner <[EMAIL PROTECTED]> wrote: > On 6/25/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Unfortunately, a mechanism that would let you register a callback for > > when a particular variable or attribute used in a cached expression is > > used, is pretty hard to implement wit

Re: [Python-Dev] Temporary Constantification

2006-06-25 Thread Eric Sumner
On 6/25/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Unfortunately, a mechanism that would let you register a callback for > when a particular variable or attribute used in a cached expression is > used, is pretty hard to implement without affecting the performance of > code that doesn't use i

Re: [Python-Dev] Temporary Constantification

2006-06-25 Thread Guido van Rossum
On 6/25/06, Eric Sumner <[EMAIL PROTECTED]> wrote: > It seems to me that the main reason to provide constantification (in a > switch statement or anywhere else) is to be able to optimize execution > by caching the result locally for later use. The problem comes from > trying to determine exactly w

Re: [Python-Dev] Temporary Constantification

2006-06-25 Thread Aahz
On Sun, Jun 25, 2006, Eric Sumner wrote: > > In general, a cached value can be used (rather than re-evaluating the > expression) if: > - The expression has no side effects, > - The result of all operations is deterministic, and > - None of the expression parameters have changed since the cach

[Python-Dev] Temporary Constantification

2006-06-25 Thread Eric Sumner
It seems to me that the main reason to provide constantification (in a switch statement or anywhere else) is to be able to optimize execution by caching the result locally for later use. The problem comes from trying to determine exactly when and how a value gets calculated, as most values in Pyth