Fwd: Overriding logical operators?

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Aug 24 07:08:09 CEST 2004


Andrew Durdin wrote:
> As far as I can see, the compiler changes would be limited to
> compiling "a and b" to bytecode equivalent to
> 
>     a.__logand__(lambda b: b)

That approach would work, but it would slow down the
evaluation of all logical expressions a lot, requiring
an extra Python function call to get the second operand,
even in the common case where no overriding is going on.
So I doubt it would be accepted.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list