__author__ = 'daitr'
#--coding:utf-8--
import datetime
#方法一:
#a=[2,3,4,5]
#b=[2,5,8]
#tmp = [val for val in a if val in b]
#print tmp
##[2, 5] #方法二
#print list(set(a).intersection(set(b)))
#print list(set(a).union(set(b)))
#print list(set(b).difference(set(a))) # b中有而a中没有的 a,b= [],[]
for i in range(1,60000):
a.append(i) for j in range(40000,100000):
b.append(j)
print a[-1]
print b[-1] time1 = datetime.datetime.now()
#print time1 tmp = [val for val in a if val in b]
#print tmp time2 = datetime.datetime.now()
#print time2
d1 = time2-time1
print d1 list(set(a).intersection(set(b)))
#print temp2 time3 = datetime.datetime.now()
#print time3
d2 = time3-time2
print d2

两个list 求交集效率对比的更多相关文章

  1. python中对两个 list 求交集,并集和差集

    python中对两个 list 求交集,并集和差集: 1.首先是较为浅白的做法: >>> a=[1,2,3,4,5,6,7,8,9,10] >>> b=[1,2,3 ...

  2. python 两个list 求交集,并集,差集

    def diff(listA,listB): #求交集的两种方式 retA = [i for i in listA if i in listB] retB = list(set(listA).inte ...

  3. Linux 两个文件求交集、并集、差集

    一.交集 sort a.txt b.txt | uniq -d 二.并集 sort a.txt b.txt | uniq 三.差集 a.txt-b.txt: sort a.txt b.txt b.tx ...

  4. list1与list2求交集的方法总结!

    一.有序集合求交集的方法有 a)二重for循环法,时间复杂度O(n*n) b)拉链法,时间复杂度O(n) c)水平分桶,多线程并行 d)bitmap,大大提高运算并行度,时间复杂度O(n) e)跳表, ...

  5. SIMD---SSE系列及效率对比

    SSE(即Streaming SIMD Extension),是对由MMX指令集引进的SIMD模型的扩展.我们知道MMX有两个明显的缺点: 只能操作整数. 不能与浮点数同时运行(MMX使用FPU寄存器 ...

  6. 【C++】Vector判断元素是否存在,去重,求交集,求并集

    1 #include <iostream> 2 #include <vector> 3 #include <algorithm> //sort函数.交并补函数 4 ...

  7. [c++]对vector<T>容器求交集,并集,去重

    #include "iostream" #include "vector" #include "algorithm" //sort函数.交并 ...

  8. 求两个集合的交集和并集C#

    我是用hashset<T>来实现的 具体如代码所示 using System; using System.Collections.Generic; using System.Linq; u ...

  9. SQLServer中求两个字符串的交集(字符串以符号分隔)

    两个字符串,以特定符号分隔(例如‘,’号),求交集 第一种情况: declare @m varchar(100),@n varchar(100)select @m=',2,3,5,7,8,9,10,' ...

随机推荐

  1. Build类

    在开发中 我们有时候会需要获取当前手机的系统版本来进行判断,或者需要获取一些当前手机的硬件信息. android.os.Build类中.包括了这样的一些信息.我们可以直接调用 而不需要添加任何的权限和 ...

  2. qt widget设置Qt::FramelessWindowHint和Qt::WA_TranslucentBackground, 会出现一个bug: 在最小化后还原时界面停止刷新

    qt widget设置Qt::FramelessWindowHint和Qt::WA_TranslucentBackground, 会出现一个bug: 在最小化后还原时界面停止刷新 Widget wit ...

  3. 疑问-hadoop

    hadoop可以设置备份数据个数,那么这些不同节点的数据块对于hadoop来说有区分谁是备份的谁是直接可以用的吗? hadoop有机架策略,给某些操作如像根据带宽选择节点传输数据 那么这种策略的根据是 ...

  4. AspxGridView整理文档【转】

    ASPxGridView属性:概述设置(Settings) <Settings GridLines="Vertical" : 网格样式 Vertical, Both, Non ...

  5. 用终端直接在桌面生成text文件

    简单的两行命令: cd Desktop/  按回车 touch 888.text 按回车就会在桌面生成名称为888的text文件 用途:做demo的时候可以加一个说明文档进去,这样下次可以很方便的查看

  6. 用java 删除mongodb的数据

    import java.net.UnknownHostException; import com.mongodb.BasicDBObject;import com.mongodb.DB;import ...

  7. 如何用拉姆达表达式(Lambda Expressions) 书写左链接查询

    在C#中,如果要实现两个列表的左链接查询,我们的一般用法就是用的linq表达式就是 List<Pet> pets = }, }, } }; List<Pet2> pets2 = ...

  8. ActiveMQ(5.10.0) - Configuring the Simple Authentication Plug-in

    The easiest way to secure the broker is through the use of authentication credentials placed directl ...

  9. AjaxPro使用方法

    无意中看到同事用AjaxPro用,看到很不错,特长是前后台传输数据特别方便. 最好的教材就是拿到就可以用,方便大家. 以前数据传输用FORM提交,或者在前台用JASON拼接然后通过AJAX方式提交.总 ...

  10. Android手机一键Root原理分析

    图/文 非虫 一直以来,刷机与Root是Android手机爱好者最热衷的事情.即使国行手机的用户也不惜冒着失去保修的风险对Root手机乐此不疲.就在前天晚上,一年一度的Google I/O大会拉开了帷 ...