[Python-3000] Python 3000 Status Update (Long!)

Christian Heimes lists at cheimes.de
Wed Jun 20 17:43:51 CEST 2007


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



More information about the Python-3000 mailing list