Map --映射

Reduce -- 归纳

将大数据标准化的处理

Map 拆封任务,Reduce将结果合并

这样是不是能够将很多计算机组成一台超级计算机呢?

一些问题:如果任务本身就很复杂,那么拆解任务本身就是一个很打的难题。

python 在2.6 的时候 增加了 map reduce函数

例如我们可以这样写

import urllib2
urls = [
'https://www.baidu.com',
'http://www.douban.com'
] resurt = map(urllib2.urlopen,urls) #等价于 resurt = []
for url in urls:
resurt.append(urllib2.urlopen(url))

 当然我们也可以加上多线程的

import urllib2
from multiprocessing.dummy import Pool as ThreadPool
urls = [
'https://www.baidu.com',
'http://www.douban.com'
] def get_html(url):
res = urllib2.urlopen(url)
html = res.read()
return html pool = ThreadPool(4)
results = pool.map(get_html,urls) pool.close()
pool.join() print results

  

04-python进阶-map&reduce的更多相关文章

  1. python基础——map/reduce

    python基础——map/reduce Python内建了map()和reduce()函数. 如果你读过Google的那篇大名鼎鼎的论文“MapReduce: Simplified Data Pro ...

  2. 使用Python实现Map Reduce程序

    使用Python实现Map Reduce程序 起因 想处理一些较大的文件,单机运行效率太低,多线程也达不到要求,最终采用了集群的处理方式. 详细的讨论可以在v2ex上看一下. 步骤 MapReduce ...

  3. Demo of Python "Map Reduce Filter"

    Here I share with you a demo for python map, reduce and filter functional programming thatowned by m ...

  4. Python: lambda, map, reduce, filter

    在学习python的过程中,lambda的语法时常会使人感到困惑,lambda是什么,为什么要使用lambda,是不是必须使用lambda? 下面就上面的问题进行一下解答. 1.lambda是什么? ...

  5. Python语言——map/reduce的用法

    Python内建了map()和reduce()函数. 如果你读过Google的那篇大名鼎鼎的论文“MapReduce: Simplified Data Processing on Large Clus ...

  6. python filter map reduce

    filter(function, iterable): Construct a list from those elements of iterable for which function retu ...

  7. python 学习 map /reduce

    python 内建了map()和reduce()函数 map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回. ...

  8. Python基础-map/reduce/filter

    一.map Python内置函数,用法及说明如下: class map(object): """ map(func, *iterables) --> map obj ...

  9. python的map,reduce函数与pandas的apply,filter函数

    1. python自带的apply.filter.map函数.reduce函数,很多情况下可以代替for循环: map(func,list),对list的每个元素分别执行func函数操作,显然func ...

随机推荐

  1. Seven Deadly Sins: Gluttony, Greed, Sloth, Wrath, Pride, Lust, and Envy.

    Seven Deadly Sins: Gluttony, Greed, Sloth, Wrath, Pride, Lust, and Envy.七宗罪:暴食.贪婪.懒惰.暴怒.傲慢.色欲.妒忌.

  2. Python+selenium之键盘事件

    keuys()类提供键盘上所有的按键方法.send_keys()方法可以用来模拟键盘输入. from selenium import webdriver from selenium.webdriver ...

  3. JavaScript空假值及其判断

    一.javaScript五种空值和假值 分别为undefined,null,false,"",0,这五个值的共同点是在执行if语句时都会执行false分支,执行对应的非语句的时候都 ...

  4. [视觉识别]OpenCV + CNN 大神符识别

    数据集 Mnist数据集:http://yann.lecun.com/exdb/mnist/ 训练 import numpy as np from keras.datasets import mnis ...

  5. Centos7.3 安装devstack stein版本

    1. 系统准备 # 关闭防火墙 systemctl stop firewalld systemctl disable firewalld # 关闭selinux setenforce 0 sed -i ...

  6. 第三单元OO总结

  7. bootstrap 翻页的状态

    翻页的状态 下面的实例演示了上表中所讨论的 class .disabled 的用法: <!DOCTYPE html><html><head><meta htt ...

  8. mutt+msmtp做linux邮件客户端

    mutt+msmtp做linux邮件客户端 1. 安装配置msmtp l  安装 wget https://sourceforge.net/projects/msmtp/files/msmtp/1.4 ...

  9. nginx访问日志(access_log)

    一.nginx访问日志介绍 nginx软件会把每个用户访问网站的日志信息记录到指定的日志文件里,供网站提供者分析用户的浏览行为等,此功能由ngx_http_log_module模块负责,对应的官方地址 ...

  10. 【Redis】DENIED Redis is running in protected mode

    .修改redis服务器的配置文件 vi redis.conf 注释以下绑定的主机地址 # bind 127.0.0.1 .修改redis服务器的参数配置 修改redis的守护进程为no ,不启用 &g ...