当前位置: 首页>>代码示例>>Python>>正文


Python IISet.has_key方法代码示例

本文整理汇总了Python中BTrees.IIBTree.IISet.has_key方法的典型用法代码示例。如果您正苦于以下问题:Python IISet.has_key方法的具体用法?Python IISet.has_key怎么用?Python IISet.has_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BTrees.IIBTree.IISet的用法示例。


在下文中一共展示了IISet.has_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_lookup

# 需要导入模块: from BTrees.IIBTree import IISet [as 别名]
# 或者: from BTrees.IIBTree.IISet import has_key [as 别名]
    def test_lookup(self):
        bigsize = 1000000
        smallsize = 1000
        large = IISet(xrange(bigsize))
        small = IISet(xrange(0, bigsize, bigsize/smallsize))

        start = time()
        for i in small:
            a = large[i]
        print "\ngetitem distributed %.6f" % (time()-start)

        start = time()
        for i in small:
            a = large[bigsize-1]
        print "getitem end %.6f" % (time()-start)

        start = time()
        for i in small:
            a = large[0]
        print "getitem start %.6f" % (time()-start)

        start = time()
        for i in small:
            a = large.has_key(i)
        print "\nhas_key distributed %.6f" % (time()-start)

        start = time()
        for i in small:
            a = large.has_key(bigsize-1)
        print "has_key end %.6f" % (time()-start)

        start = time()
        for i in small:
            a = large.has_key(0)
        print "has_key start %.6f" % (time()-start)
开发者ID:hannosch,项目名称:experimental.catalogqueryplan,代码行数:37,代码来源:test_performance.py

示例2: ZchSite

# 需要导入模块: from BTrees.IIBTree import IISet [as 别名]
# 或者: from BTrees.IIBTree.IISet import has_key [as 别名]

#.........这里部分代码省略.........
            manage_addLexicon(self,id='lexicon',elements = elements)

        self.__of__(parent)._buildIndexing(id,title)

        t=time()     
        self.created  = t     
        self.modified = t     

        self.fileattache = fileattache

        self.data     =IOBTree()  # id -> Message     
        self.ids      =IISet() # ids of children

        self.loadSkelton(None, skelton)
        self.loadProperties(skelton)
        self.skelton = skelton

    security.declarePublic('__len__')
    def __len__(self):
        return len(self.ids) + 1     
     
    security.declareProtected(View, '__getitem__')
    def __getitem__(self,id):
        """ Get a posting from the ZchSite data store """
    
        # make sure id is an integer
        try:
            if not isinstance(id,IntType):
                id=atoi(id)
        except ValueError:
            raise KeyError, id
    
        # make sure it's in our list of children
        if not self.ids.has_key(id):
            raise KeyError, id
            
        # return the posting
        return self.data[id].__of__(self)
     
    security.declareProtected(View, 'zchcrypt')
    def zchcrypt(self,word,key):        
        import hmac, base64
        h = hmac.new(key)
        h.update(word)
        return base64.encodestring(h.digest())[:-3]

    security.declareProtected(View, 'zchfqdn')
    def zchfqdn(self,n):        
        return getfqdn(n)

    security.declarePrivate('delItem')
    def delItem(self,id):
        if not self.data.has_key(id):
            return

        if self.ids.has_key(id): # article
            article = self.data[id].__of__(self)
            for comment_id in article.ids:     
                obj = self.data[comment_id].__of__(article)
                self.uncatalog_object(obj.getPhysicalPath())
                del self.data[comment_id]
            self.uncatalog_object(article.getPhysicalPath())
            del self.data[id]
            self.ids.remove(id)
        else: # comment
            parent = self.data[self.data[id].parent_id].__of__(self)
开发者ID:nakagami,项目名称:Products.Zch,代码行数:70,代码来源:ZchSite.py


注:本文中的BTrees.IIBTree.IISet.has_key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。