Lazy evaluation: overloading the assignment operator?
Antoon Pardon
apardon at forel.vub.ac.be
Thu May 3 08:33:45 EDT 2007
On 2007-05-03, sturlamolden <sturlamolden at yahoo.no> wrote:
> On May 3, 6:22 am, Charles Sanders <C.delete_this.Sand... at BoM.GOv.AU>
> wrote:
>
>> y = a*b+c*d # Returns a proxy object
>>
>> x = y[4] # Computes x = a[4]*b[4] + c[4]*d[4]
>>
>> v = y.eval() # Evaluates all elements, returning Xarray
>>
>> z = ((a+b)*(c+d)).eval() # Also evaluates all elements
>
> When I suggested this on the NumPy mailing list, I too suggested using
> the indexing operator to trigger the computations. But I am worried
> that if an expression like
>
> y = a*b+c*d
>
> returns a proxy, it is somehow possible to mess things up by creating
> cyclically dependent proxies. I may be wrong about this, in which case
> __getitem__ et al. will do the job.
How do you expect to handle the following kind of situation:
while <condition>:
x = y
a = ...
b = ...
y = a * x + b
--
Antoon Pardon
More information about the Python-list
mailing list