Message150303
| Author |
JBernardo |
| Recipients |
JBernardo, benjamin.peterson, georg.brandl, pitrou |
| Date |
2011年12月28日.16:58:28 |
| SpamBayes Score |
4.8336946e-11 |
| Marked as misclassified |
No |
| Message-id |
<1325091509.16.0.812673048109.issue13667@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I see that every other comparison operator (<, >, <=, >=, ==, !=) except for `is` work the way I expect and is able to return anything.
e.g.
>>> numpy.arange(5) < 3
array([ True, True, True, False, False], dtype=bool)
I didn't checked the code (and probably I'm talking nonsense), but seems like the `in` operator has an extra call to `PyObject_IsTrue` that maybe could be dropped?
Of course it can break code relying on `x in y` being True/False but it would only happen on customized classes.
Another option that won't break code is to add a different method to handle these cases. Something like "__contains_non_bool__", but that'd be a big api change. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年12月28日 16:58:29 | JBernardo | set | recipients:
+ JBernardo, georg.brandl, pitrou, benjamin.peterson |
| 2011年12月28日 16:58:29 | JBernardo | set | messageid: <1325091509.16.0.812673048109.issue13667@psf.upfronthosting.co.za> |
| 2011年12月28日 16:58:28 | JBernardo | link | issue13667 messages |
| 2011年12月28日 16:58:28 | JBernardo | create |
|