Performance comment (oddity with set.update())

Torsten Bronger bronger at physik.rwth-aachen.de
Wed Apr 23 05:38:03 BST 2008


Hallöchen!

Robert Collins writes:

> On Tue, 2008-04-22 at 16:49 -0500, John Arbash Meinel wrote:
>
>> I was just debugging some performance issues, and I came across
>> something funny.
>> 
>> Specifically, calling 'set.update()' with a generator that
>> returns nothing is slower than building it into a list and then
>> updating.
>
> I think this is worth filing a python bug on, so that the python
> devs are aware of it.

I think the actual benefit of a generator is its reduced memory
consumption rather than higher speed.  Apparently, building a
generator has slightly higher fixed costs.  Getting the next element
is almost as costly for the generator as for the list (while
building it), so their performances behave asymptotically for many
iterations.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                                      Jabber ID: bronger at jabber.org
               (See http://ime.webhop.org for further contact info.)




More information about the bazaar mailing list