__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. Spark之路 --- Scala IDE Maven配置(使用开源中国的Maven库)和使用

    为什么要使用Maven 摘自百度百科的介绍 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具.Maven 除了以程序构建能力为特色之外,还提 ...

  2. Helpers\Pagination

    Helpers\Pagination Break recordset into a series of pages. First create a new instance of the class ...

  3. Computer skills one can learn within one day

    Computer related technical skills are usually thought as complicated and difficult to understand. It ...

  4. sed程序

    程序1: 实现简单的shell sed替换功能 程序2:修改haproxy配置文件  1.查 输入:www.oldboy.org 获取当前backend下的所有记录 2.新建 输入: arg = { ...

  5. Scala中的Map

    映射 映射是对偶的集合. 声明映射 映射是对偶的集合. a.声明映射 b.映射中的键值对称作对偶,用( , )表示 c.当映射中不存在key时,取值会报错,解决方案是使用 contains方法,或者g ...

  6. 并查集(UVA 1106)

    POINT: 把每个元素看成顶点,则一个简单化合物就是一条无向边,若存在环(即k对组合中有k种元素),则危险,不应该装箱,反之,装箱: 用一个并查集维护连通分量集合,每次得到一种化合物(x, y)时检 ...

  7. Codevs 3729==洛谷P1941 飞扬的小鸟

    P1941 飞扬的小鸟 456通过 2.4K提交 题目提供者该用户不存在 标签动态规划2014NOIp提高组 难度提高+/省选- 提交该题 讨论 题解 记录   题目描述 Flappy Bird 是一 ...

  8. 详解Win2003 IIS6.0 301重定向带参数的问题(转摘)

      网站更换域名,把旧域名用301指到新域名来. 从iis中设置url永久转向就可以,看上去很容易,用了一会儿才发现,参数都没有带上. 从微软网站上找到如下说明,果然好使: 重定向参考 (IIS 6. ...

  9. Android 中的 Service 全面总结 (转)

    原文地址:http://www.cnblogs.com/newcj/archive/2011/05/30/2061370.html 1.Service的种类   按运行地点分类: 类别 区别  优点 ...

  10. 远程连接MySql连不上1130

    mysql数据库user表中已存在主机=%的用户root,连接却提示1130. 用navicat开启user表>>>>在表里直接修改%账户root的密码(看到是未加密过的内容) ...