[issue2672] speed of set.update(

2008-04-24 Thread John Arbash Meinel
John Arbash Meinel [EMAIL PROTECTED] added the comment: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alexander Belopolsky wrote: Alexander Belopolsky [EMAIL PROTECTED] added the comment: This has nothing to do with set.update, the difference is due to the time to setup the generator: $

[issue2672] speed of set.update(

2008-04-24 Thread Alexander Belopolsky
Alexander Belopolsky [EMAIL PROTECTED] added the comment: On Thu, Apr 24, 2008 at 2:23 PM, John Arbash Meinel [EMAIL PROTECTED] wrote: .. So if you compare consuming a generator multiple times to creating it each time, it is 0.662 usec - 0.173 usec = 0.489 usec to create a generator. So

[issue2672] speed of set.update(

2008-04-24 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: John, when y=[], the update method has to create a new list iterator on each invocation. But when y is a genexp, it is self-iterable (iow, iter (y) will return self, not a new object). Also, when doing timings, it can be helpful to

[issue2672] speed of set.update(

2008-04-24 Thread John Arbash Meinel
John Arbash Meinel [EMAIL PROTECTED] added the comment: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Raymond Hettinger wrote: Raymond Hettinger [EMAIL PROTECTED] added the comment: John, when y=[], the update method has to create a new list iterator on each invocation. But when y is a

[issue2672] speed of set.update([])

2008-04-23 Thread Alexander Belopolsky
Alexander Belopolsky [EMAIL PROTECTED] added the comment: This has nothing to do with set.update, the difference is due to the time to setup the generator: $ python -m timeit -s 'x = set(range(1)); y = []' 'x.update(y)' 100 loops, best of 3: 0.38 usec per loop $ python -m timeit -s 'x =

[issue2672] speed of set.update([])

2008-04-23 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: I concur. The source code for set_update() in Objects/setobject.c shows that both versions are accessed through the iterator protocol, so what you're seeing are the basic performance differences (start-up and per-item costs) for genexps

[issue2672] speed of set.update([])

2008-04-22 Thread John Arbash Meinel
New submission from John Arbash Meinel [EMAIL PROTECTED]: I was performance profiling some of my own code, and I ran into something unexpected. Specifically, set.update(empty_generator_expression) was significantly slower than set.update(empty_list_expression). I double checked my findings with

[issue2672] speed of set.update([])

2008-04-22 Thread John Arbash Meinel
Changes by John Arbash Meinel [EMAIL PROTECTED]: -- type: - performance __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2672 __ ___ Python-bugs-list mailing list

[issue2672] speed of set.update([])

2008-04-22 Thread Raymond Hettinger
Changes by Raymond Hettinger [EMAIL PROTECTED]: -- assignee: - rhettinger nosy: +rhettinger __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue2672 __ ___ Python-bugs-list