示例#1
0
文件: core.py 项目: fxsjy/sdict
	def __init__(self,py_list=[]):
		self.__is_int_flag__ = 0
		self.__tst__ = tst.create_tst_db()
		py_list = list(py_list)

		if isinstance(py_list,list):
			if len(py_list)>0:
				if not isinstance(py_list[0],tuple):
					raise Exception("invalid list to generate dictionary")

				if isinstance(py_list[0][0],int):
					py_list = [(str(x).zfill(10),y) for x,y in py_list]
					self.__is_int_flag__ = 1
				if not isinstance(py_list[0][0],str):
					raise Exception('invalid key type')

				tst.tst_from_list(self.__tst__, py_list)	
		else:
			raise Exception("need a list, but got a "+str(type(py_list)))
示例#2
0
文件: bench.py 项目: fxsjy/sdict
import tst
db = tst.create_tst_db()
for i in xrange(10000001):
	tst.tst_put(db,str(i),i)
	if i%100000 ==0 :
		print 'inserting', i
for i in xrange(20):
	print tst.tst_get(db,str(i))