inertia的博客

细推物理需行乐,何将浮名绊此生


  • 首页

  • 标签

  • 分类

  • 归档

利用multiprocessing使Python进行并行计算

发表于 2018-07-23 | 分类于 教程 | 评论数: 0 | 阅读次数: 0

由于CPython中GIL的存在,python几乎无法用于并行计算,但是我们可以通过调用multiprocessing模块来使Python进行并行计算。
示例代码如下

1
2
3
4
5
6
7
8
9
10
11
import multiprocessing

def f(x):
return x * x

cores = multiprocessing.cpu_count()
pool = multiprocessing.Pool(processes=cores) #给定线程数
xs = range(5)
print(pool.map(f,xs))
pool.close()
pool.join()

  1. 使用前注意调用multiprocessing模块,在Python3中,该库并非第三方库,因此可以直接调用
  2. cpu密集型计算尽量让线程数接近核数,io密集型则不一定。

How to install ArchiSteamFarm on ubuntu 16.04

发表于 2018-07-22 | 分类于 教程 | 评论数: | 阅读次数: 0

由于一些原因,这篇文章是用英文写的,不过鉴于我的英文水平,写得都很简单,全是大白话,实在不行用google翻译一下就行了(逃

Introduction

ArchiSteamFarm is a powerful open-source application that help you farm steam cards offline. It doesn’t require steam client running in background.It has a lot of advantages:

  1. It allows you to farm cards using multiple steam accounts simultaneously.
  2. It doesn’t need the Steam client.
  3. Its special algorithms can improve the efficiency of farming cards.
  4. It is VAC-free.
  5. If you are playing game, it will pause automatically.

This article will show you how to install ArchiSteamFarm on a Vultr Ubuntu 16.04 server instance.

阅读全文 »

Python使用相关技巧

发表于 2018-07-22 | 分类于 教程 | 评论数: | 阅读次数: 0

在没有GUI的情况下使用matplotlib

在vps上运行调用matplotlib的python脚本时需在import matplotlib.pyplot前加上

1
2
import matplotlib as mpl
mpl.use('Agg')

一定要加在import matplotlib.pyplot前

给pip更换源

将windows下的pip源换为清华的源

只需要在user文件夹下新建pip文件夹,并在其中新建pip.ini文件,并写入:

1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

即可

Hexo使用相关技巧

发表于 2018-07-19 | 分类于 教程 | 评论数: | 阅读次数: 0

平时收集的一些Hexo使用的技巧

阅读全文 »

Hexo 博客搭建指南!

发表于 2018-07-19 | 分类于 教程 | 评论数: | 阅读次数: 0

1 Hexo介绍

Hexo是基于NodeJs的静态博客框架,简单、轻量,其生成的静态网页可以托管在Github和Heroku上。

  • 超快速度
  • 支持MarkDown
  • 一键部署
  • 丰富的插件
阅读全文 »
12
inertia

inertia

18 日志
2 分类
19 标签
© 2018 — 2020 inertia
由 Hexo 强力驱动
|
主题 — NexT.Pisces
15804 20638