On Fri, Sep 16, 2011 at 8:19 PM, Grant Edwards <invalid@invalid.invalid> wrote:
>> Here's another one-liner using a generator instead of map:
>>
>>      sum(int(c) for c in str(2**1000))
>
> Just in case you can't spare the 3KB required for the list of integers
> that map creates. :)
>
> In this case it doesn't matter, but it's not hard to find problems
> where the difference between the memory requirements for a generator
> and a map/list-comprehension are significant enough to worry about.

Unless otherwise specified, I generally assume that code on this list
is for Python 3, and map in Python 3 returns an iterator.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to