[Python-Dev] filter(bool, ...)
Guido van Rossum
guido at python.org
Thu Aug 14 12:27:17 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 {
Cute. But I still think it's better to spell this as
list(x)
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list