本文整理匯總了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)
示例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)