Bugs item #1517509, was opened at 2006-07-05 09:09 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1517509&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Collin Winter (collinwinter) Assigned to: Nobody/Anonymous (nobody) Summary: filter() implementation does not match docs Initial Comment: The docs for the built-in function filter() claim that "filter(function, list) is equivalent to [item for item in list if function(item)] if function is not None and [item for item in list if item] if function is None". >>> class infinite_str(str): ... def __getitem__(self, index): ... return "a" ... >>> filter(None, infinite_str("1234")) 'aaaa' Now, if we translate this to a listcomp according to the docs: >>> [x for x in infinite_str("1234") if x] The listcomp version proceeds to chew up memory until it exhausts the system resources or is killed by the user. If the docs are to be believed, the filter() version should do the same thing. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1517509&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com