[Python-Dev] ANN: PEP 335: Overloadable Boolean Operators

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Sep 15 03:15:09 CEST 2004


"Phillip J. Eby" <pje at telecommunity.com>:

> So, something like this:
> 
>       query("x and y or z")
> 
> isn't "code that performs database queries"?

Yes, but it's not Python code - it's SQL code wrapped
in a string wrapped in Python code. I want just Python
code.

> My main concern about the PEP is that it adds overhead to *all*
> logical operations, but the feature will only benefit code that
> hasn't yet been written.

The overhead shouldn't be substantially worse than that already
incurred by all the other operators being overloadable.  Also,
realistically, how much code do you think has boolean operations as a
speed bottleneck? I find it hard to imagine what such code would be
like.

> I also fear that as a result, people will start writing complex
> if-then blocks to "optimize" performance of conditionals to get them
> back to where they were before the facility was added.

If people do that, they're guilty of premature optimisation if they
haven't actually measured the speed of their code and found an actual
problem with it. I expect such cases will be extremely rare if they
occur at all.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list