[docs] [issue18032] set methods should specify whether they consume iterators "lazily"

Raymond Hettinger report at bugs.python.org
Mon May 27 09:59:28 CEST 2013

Raymond Hettinger added the comment:

We don't normally document implementation details or the presences or absence of internal optimizations.  This gives us freedom to change the implementation and it allows freedom for other implementations (such as Jython, IronPython, and PyPy) to make their own choices.  Often those implementations start out with the simplest correct approach and then become increasingly optimized over time. 

I'm leaving this one open as a possible CPythhon performance enhancement, adding early-out behavior to issubset() when the argument is a non-set, non-dict iterable:

    def issubset(self, iterable):
        n = len(self)
        seen = set() 
        for x in iterable:
            if x not in seen and x in self:
                n -= 1
                if not n:
                    return True             # early-out
        return False

components: +Interpreter Core -Documentation
type: behavior -> performance
versions:  -Python 2.7, Python 3.3

Python tracker <report at bugs.python.org>

More information about the docs mailing list