Nick Coghlan wrote: > Because (str(x) for x in seq) is not an improvement over map(str, x) - > applying a single existing function to a sequence is a very common > operation. > > map() accepts any function (given an appropriate number of sequences), > and thus has wide applicability. > > filter() accepts any single argument predicate function (using bool() by > default), and thus also has wide applicability.
But map() and filter() can be easily replaced with a generator or list comprehensive expression. [str(x) for x in seq] and [x for x in seq if func(x)] are consider easier to read these days. IIRC map and filter are a bit slower than list comprehensive and may use much more memory than a generator expression since map and filter are returning a list of results. Personally I don't see the reason why map and filter are still builtins when they can be replaced with easier to read, faster and less memory consuming code. OK, I have to type some more characters but that's not an issue for me. Christian _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com