This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients abacabadabacaba, belopolsky, eric.smith, ezio.melotti, r.david.murray, rhettinger
Date 2010-05-10.18:51:22
SpamBayes Score 1.1110017e-07
Marked as misclassified No
Message-id <1273517484.93.0.347291477114.issue8425@psf.upfronthosting.co.za>
In-reply-to
Content
Note that issue8425a.diff leaves small_set.difference_update(large_dict) unoptimized:

$ ./python.exe -m timeit -s "s = {1}; l = dict.fromkeys(range(1000));" "s.difference_update(l)"
1000 loops, best of 3: 842 usec per loop
$ ./python.exe -m timeit -s "s = {1}; l = dict.fromkeys(range(1000));" "s.difference(l)"
100000 loops, best of 3: 13.2 usec per loop

It would be easy to add an extra type check, but I noticed that small_set.difference_update(large_dict.viewkeys()) is not optimized either:

$ ./python.exe -m timeit -s "s = {1}; l = dict.fromkeys(range(1000));" "s.difference(l.viewkeys())"
1000 loops, best of 3: 842 usec per loop

It would be nice if there was a uniform C-API that would allow to uniformly check that an object supports O(1) lookup and invoke such lookup efficiently.  I don't think such C-API exists at the moment.

I would like to hear what others have to say before adding optimizations  to the patch that go beyond the scope of this issue.
History
Date User Action Args
2010-05-10 18:51:25belopolskysetrecipients: + belopolsky, rhettinger, eric.smith, ezio.melotti, r.david.murray, abacabadabacaba
2010-05-10 18:51:24belopolskysetmessageid: <1273517484.93.0.347291477114.issue8425@psf.upfronthosting.co.za>
2010-05-10 18:51:22belopolskylinkissue8425 messages
2010-05-10 18:51:22belopolskycreate