<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Could you provide some links to where this could be useful, and how code could be rewritten? I can see the desire for such a feature, I myself would have liked such an operator or keyword. If you get general approval on this list, you can then move on to write a PEP (as that's what's needed if you wish to add a new keyword and/or operator to the language).<div><br></div><div>I'm +0 for now, and may change once you provide us with use cases in the wild.</div><div>-Emanuel</div><div><br><div><hr id="stopSpelling">From: me@jeltef.nl<br>Date: Mon, 23 Nov 2015 20:09:17 +0100<br>To: python-ideas@python.org<br>Subject: [Python-ideas] [Python-ideos] Dedicated overloadable boolean operators<br><br><div dir="ltr"><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;">Hi,</div><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;"><br></div><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;">After reading </span><a href="https://www.python.org/dev/peps/pep-0465/" target="_blank" rel="nofollow" style="padding:0px;border:0px;text-decoration:none;color:rgb(102,17,204);font-family:Arial,Helvetica,sans-serif;font-size:13px;">PEP0465</a><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;"> about the dedicated matrix multiplication I started wondering if the same solution couldn't be applied to boolean operators as well. There currently are a lot of high profile libraries that have their own functions for boolean operators, like Numpy, Pandas or SQLAlchemy. They do this because the current boolean operators can't be overloaded. </span><a href="https://www.python.org/dev/peps/pep-0335/" target="_blank" rel="nofollow" style="padding:0px;border:0px;text-decoration:none;color:rgb(102,17,204);font-family:Arial,Helvetica,sans-serif;font-size:13px;">PEP0335</a><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;"> was created to solve this problem (and makes the problem more clear), but was rejected because it needed changes to the byte code for the boolean operators, which would make them slower. </span><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;">Currently some of these libraries resort to the bitwise operators (at least Pandas), but those don't bind as strong as comparison operators, which means you have to do comparisons like this: (series1 == 2) & (series2 == 3) </span><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;"><br></div><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;">That is why I propose to create new operators just like for matrix multiplication which can be used in libraries that need one. I'm not sure what the operators should look like, but my first guess would be &&, || and ! for and, or and not respectively. </div><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;"><br></div><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;">Is this an idea that sounds reasonable?</div><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;"><br></div><div style="padding:0px;border:0px;font-family:Arial,Helvetica,sans-serif;font-size:13px;">Jelte</div></div>
<br>_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/</div></div>                                     </div></body>
</html>