[New-bugs-announce] [issue22451] filtertuple, filterstring and filterunicode don't have optimization for PyBool_Type
Joshua Landau
report at bugs.python.org
Sun Sep 21 03:04:35 CEST 2014
New submission from Joshua Landau:
All code referred to is from bltinmodule.c, Python 2.7.8:
https://github.com/python/cpython/blob/2.7/Python/bltinmodule.c
filter implements and optimization for PyBool_Type, making it equivalent to PyNone:
# Line 303
if (func == (PyObject *)&PyBool_Type || func == Py_None)
The specializations for tuples, byte strings and unicode don't have this:
# Lines 2776, 2827, 2956, 2976
if (func == Py_None)
This is a damper against recommending `filter(bool, ...)`.
---
Python 3 of course does not have these specializations, so has no bug.
----------
components: Library (Lib)
messages: 227199
nosy: Joshua.Landau
priority: normal
severity: normal
status: open
title: filtertuple, filterstring and filterunicode don't have optimization for PyBool_Type
type: performance
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22451>
_______________________________________
More information about the New-bugs-announce
mailing list