(1) Is there a reason that you never shrink sets for discard/remove/pop?
(set difference will do a one-time shrink, if there are enough dummy
entries, but even then, it doesn't look at the %filled, so a
merge-related overallocation will stick around)
I note the you do the same with dicts, but I think sets are a more
natural candidate for "this is the set of things I still have to
process, in any order". (I suppose enforcing an order with deque may
be faster -- unless I'm worried about duplicates.)
(2) When adding an element, you check that
if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2))
Is there any reason to use that +1? Without it, resizes will happen
element sooner, but probably not much more often -- and you could
avoid an add on every insert.
(I suppose dictionaries have the same question.)
(3) In set_merge, when finding the new size, you use (so->fill + other->used)
Why so->fill? If it is different from so->used, then the extras are
dummy entries that it would be good to replace.
(I note that dictobject does use ->used.)
-jJ
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com