Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
Am curious about your use cases. ISTM that in every case I've every used either function, I've always known that the attribute or item is going to be there. For instance, the original motivating use cases were to support the key= argument to min/max/sorted/nlargest/nsmallest/groupby and to support iterator algebra with itertools: def powerset(iterable): '''Iterate over all subsets. >>> list(powerset('abc')) [set([]), set(['a']), set(['b']), set(['a', 'b'])] ''' # Only 1 initial call to PyObject_Hash(). # No trips around the eval-loop. # Memory friendly. seq = map(set, list(iterable)[::-1]) selector_stream = product([False, True], repeat=len(seq)) newsets, ns1 = tee(starmap(set, repeat(()))) components = imap(compress, repeat(seq), selector_stream) sets_and_components = imap(chain, izip(newsets), components) results = starmap(set.update, sets_and_components) return imap(itemgetter(0), izip(ns1, results)) _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4124> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com