def __contains__(self, item): obj = capi.nl_cache_search(self._nl_cache, item._nl_object) if obj is None: return False else: capi.nl_object_put(obj) return True
def next(self): if self._end: raise StopIteration() if self._first: ret = self._nl_object self._first = 0 else: ret = self.get_next() if not ret: self._end = 1 raise StopIteration() # return ref of previous element and acquire ref of current # element to have object stay around until we fetched the # next ptr capi.nl_object_put(self._nl_object) capi.nl_object_get(ret) self._nl_object = ret # reference used inside object capi.nl_object_get(ret) return self._cache._new_object(ret)
def __del__(self): if self._nl_object: capi.nl_object_put(self._nl_object)
def __del__(self): if not self._nl_object: raise ValueError() capi.nl_object_put(self._nl_object)