def succ_item(self, key, default=_sentinel):
        """Get successor (k,v) pair of key, raises KeyError if key is max key
        or key does not exist. optimized for pypy.
        """
        # removed graingets version, because it was little slower on CPython and much slower on pypy
        # this version runs about 4x faster with pypy than the Cython version
        # Note: Code sharing of succ_item() and ceiling_item() is possible, but has always a speed penalty.
        node = self._root
        succ_node = None
        while node is not None:
            cmp = self._cmp(self._cmp_data, key, node.key)
            if cmp == 0:
                break
            elif cmp < 0:
                if (succ_node is None) or self._cmp(self._cmp_data, node.key, succ_node.key) < 0:
                    succ_node = node
                node = node.left
            else:
                node = node.right

        if node is None:  # stay at dead end
            if default is _sentinel:
                raise KeyError(str(key))
            return default
        # found node of key
        if node.right is not None:
            # find smallest node of right subtree
            node = node.right
            while node.left is not None:
                node = node.left
            if succ_node is None:
                succ_node = node
            elif self._cmp(self._cmp_data, node.key, succ_node.key) < 0:
                succ_node = node
        elif succ_node is None:  # given key is biggest in tree
            if default is _sentinel:
                raise KeyError(str(key))
            return default
        return succ_node.key, succ_node.value
def succ_item(self, key, default=_sentinel):
        """Get successor (k,v) pair of key, raises KeyError if key is max key
        or key does not exist. optimized for pypy.
        """
        # removed graingets version, because it was little slower on CPython and much slower on pypy
        # this version runs about 4x faster with pypy than the Cython version
        # Note: Code sharing of succ_item() and ceiling_item() is possible, but has always a speed penalty.
        node = self._root
        succ_node = None
        while node is not None:
            cmp = self._cmp(self._cmp_data, key, node.key)
            if cmp == 0:
                break
            elif cmp < 0:
                if (succ_node is None) or self._cmp(self._cmp_data, node.key, succ_node.key) < 0:
                    succ_node = node
                node = node.left
            else:
                node = node.right

        if node is None:  # stay at dead end
            if default is _sentinel:
                raise KeyError(str(key))
            return default
        # found node of key
        if node.right is not None:
            # find smallest node of right subtree
            node = node.right
            while node.left is not None:
                node = node.left
            if succ_node is None:
                succ_node = node
            elif self._cmp(self._cmp_data, node.key, succ_node.key) < 0:
                succ_node = node
        elif succ_node is None:  # given key is biggest in tree
            if default is _sentinel:
                raise KeyError(str(key))
            return default
        return succ_node.key, succ_node.value
def succ_item ( self , key , default = _sentinel ) : # removed graingets version, because it was little slower on CPython and much slower on pypy # this version runs about 4x faster with pypy than the Cython version # Note: Code sharing of succ_item() and ceiling_item() is possible, but has always a speed penalty. node = self . _root succ_node = None while node is not None : cmp = self . _cmp ( self . _cmp_data , key , node . key ) if cmp == 0 : break elif cmp < 0 : if ( succ_node is None ) or self . _cmp ( self . _cmp_data , node . key , succ_node . key ) < 0 : succ_node = node node = node . left else : node = node . right if node is None : # stay at dead end if default is _sentinel : raise KeyError ( str ( key ) ) return default # found node of key if node . right is not None : # find smallest node of right subtree node = node . right while node . left is not None : node = node . left if succ_node is None : succ_node = node elif self . _cmp ( self . _cmp_data , node . key , succ_node . key ) < 0 : succ_node = node elif succ_node is None : # given key is biggest in tree if default is _sentinel : raise KeyError ( str ( key ) ) return default return succ_node . key , succ_node . value
Get successor (k,v) pair of key, raises KeyError if key is max key
        or key does not exist. optimized for pypy.
Get successor ( k v ) pair of key raises KeyError if key is max key or key does not exist . optimized for pypy .