[Python-Dev] filter(bool, ...)
Neil Schemenauer
nas at python.ca
Thu Aug 14 12:10:58 EDT 2003
I just realized that filter(bool, ...) is the same as filter(None, ...).
Anyone object to optimizing the 'bool' case? I think using 'bool' is
much clearer than 'None'.
Neil
Index: Python/bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.293
diff -u -r2.293 bltinmodule.c
--- Python/bltinmodule.c 2 Aug 2003 07:42:56 -0000 2.293
+++ Python/bltinmodule.c 14 Aug 2003 17:49:26 -0000
@@ -197,7 +197,7 @@
break;
}
- if (func == Py_None) {
+ if (func == Py_None || func == (PyObject *)&PyBool_Type) {
ok = PyObject_IsTrue(item);
}
else {
More information about the Python-Dev
mailing list