homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author collinwinter
Recipients
Date 2006年07月05日.13:09:25
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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. 
History
Date User Action Args
2007年08月23日 14:41:07adminlinkissue1517509 messages
2007年08月23日 14:41:07admincreate

AltStyle によって変換されたページ (->オリジナル) /