Re: Lazy evaluation: overloading the assignment operator?

2007-05-03 Thread Antoon Pardon
On 2007-05-03, Terry Reedy [EMAIL PROTECTED] wrote: sturlamolden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | | Python allows the binding behaviour to be defined for descriptors, | using the __set__ and __get__ methods. I think it would be a major | advantage if this could be

Re: Lazy evaluation: overloading the assignment operator?

2007-05-03 Thread sturlamolden
On May 3, 6:22 am, Charles Sanders [EMAIL PROTECTED] 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

Re: Lazy evaluation: overloading the assignment operator?

2007-05-03 Thread Antoon Pardon
On 2007-05-03, sturlamolden [EMAIL PROTECTED] wrote: On May 3, 6:22 am, Charles Sanders [EMAIL PROTECTED] 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

Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread sturlamolden
Python allows the binding behaviour to be defined for descriptors, using the __set__ and __get__ methods. I think it would be a major advantage if this could be generalized to any object, by allowing the assignment operator (=) to be overloaded. One particular use for this would be to implement

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread Stargaming
sturlamolden wrote: Python allows the binding behaviour to be defined for descriptors, using the __set__ and __get__ methods. AFAIK, __getattribute__ calls them *explicitly*. I think it would be a major advantage if this could be generalized to any object, by allowing the assignment

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread Diez B. Roggisch
sturlamolden schrieb: Python allows the binding behaviour to be defined for descriptors, using the __set__ and __get__ methods. I think it would be a major advantage if this could be generalized to any object, by allowing the assignment operator (=) to be overloaded. One particular use for

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread sturlamolden
On May 2, 9:46 pm, Stargaming [EMAIL PROTECTED] wrote: del tmp2 y = tmp3 # tmp3 gets evaluated as assignment is overloaded To allow lazy evaluation, you need overloading of the assignment operator? No I don't. I could for example delay evaluation until some data from y is requested, say

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread sturlamolden
On May 2, 11:08 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: And AFAIK the general overhead of laziness versus eager evaluation does not pay off - haskell is a tad slower than e.g. an ML dialect AFAIK. In the numerical Python community there is already a prototype compiler called 'numexpr'

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread Terry Reedy
sturlamolden [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | | Python allows the binding behaviour to be defined for descriptors, | using the __set__ and __get__ methods. I think it would be a major | advantage if this could be generalized to any object, by allowing the | assignment

Re: Lazy evaluation: overloading the assignment operator?

2007-05-02 Thread Charles Sanders
Diez B. Roggisch wrote: I fail to see where laziness has anything to do with this. In C++, this problem can be remedied with the so called temporary base class idiom. I have seen this referred to as lazy evaluation in C++, so I suspect that Diez and Sturia are using Lazy evaluation