__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. js new date详解

    创建一个日期对象: var objDate=new Date([arguments list]); var ini_date=new Date(2014,7,0); //是代表7月最后一天 ,也就是2 ...

  2. Undefined property: Illuminate\Database\Eloquent\Builder

    是因为在 $activity=Activity::where('center_id','=',$center->id)->where('Date','=',date("Y-m-d ...

  3. Linux shell 脚本攻略之批量重命名

    摘自:<Linux shell 脚本攻略>

  4. 自定义 Yasnippet 模板

    yasnippet可以把我们常用的代码段或文本储存起来,到使用的时候只需键入几个字母就会自动带出. 比如我们在写python代码时,常常会在文件的第一行写下: #!/usr/bin/env pytho ...

  5. myeclipse web 包名保留字与servlet冲突

    包名不能取modify ..........等保留字 不能有数字

  6. .net mvc sample 参考网址

    http://www.asp.net/mvc/samples     http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store- ...

  7. FZU 1686 神龙的难题 (DLX)

    神龙的难题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  8. hdu 4005 边连通度与缩点

    思路:先将图进行缩点,建成一颗树,那么如果这是一条单路径树(即最大点度不超过2),就不在能删的一条边,使得不连通.因为将其头尾相连,形成一个圈,那么删任意一条边,图都是连通的. 上面的是无解的情况,如 ...

  9. DOM操作在jQuery中的实用------文字提示和图片提示

    关于文字提示想必是家喻户晓,操作呢说简单一点就是在超链接中加入title属性.但是在人机交互越来越倍受恩宠的年代,依靠浏览器自带的文字提示即title属性,提示效果的响应速度就(还是人艰不拆了吧~)s ...

  10. C#算法基础之快速排序

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...