Jaime Fernandez del Rio wrote:

>> (1) building another throwaway list and
>> (2) function call overhead for calling doit()
>>
>> You can avoid (1) by using filter() instead of map()
> 
> Are you sure of this? 

> I'm afraid there is no builtin function to do an inplace modification
> of a sequence...
 
You are right. 

But the OP invokes map() for the side effect of calling doit(item) for every 
item in the (huge) list and then gets another list of the same length 
containing only None values. by using filter() instead of map() with doit 
always returning None he gets an empty result list which means less wasted 
effort:

>>> items = range(10)
>>> map(doit, items)
[None, None, None, None, None, None, None, None, None, None]
>>> filter(doit, items)
[]

Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to