Skip to content

Commit

Permalink
更新了部分文档补充了Linux部分的内容
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrued committed Jun 2, 2019
1 parent 4082e1a commit b74e0de
Show file tree
Hide file tree
Showing 14 changed files with 609 additions and 177 deletions.
Binary file removed .DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions Day16-20/Python语言进阶.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
# 第二天A第一个醒来 他将鱼分为5份 扔掉多余的1条 拿走自己的一份
# B第二个醒来 也将鱼分为5份 扔掉多余的1条 拿走自己的一份
# 然后C、D、E依次醒来也按同样的方式分鱼 问他们至少捕了多少条鱼
fish = 1
fish = 6
while True:
total = fish
enough = True
Expand All @@ -232,7 +232,7 @@
if enough:
print(fish)
break
fish += 1
fish += 5
```

贪婪法例子:假设小偷有一个背包,最多能装20公斤赃物,他闯入一户人家,发现如下表所示的物品。很显然,他不能把所有物品都装进背包,所以必须确定拿走哪些物品,留下哪些物品。
Expand Down Expand Up @@ -769,6 +769,8 @@
main()
```

> 说明:上面的代码中使用了Emoji字符来表示扑克牌的四种花色,在某些不支持Emoji字符的系统上可能无法显示。

- 对象的复制(深复制/深拷贝/深度克隆和浅复制/浅拷贝/影子克隆)

- 垃圾回收、循环引用和弱引用
Expand Down
50 changes: 50 additions & 0 deletions Day16-20/code/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
多进程和进程池的使用
多线程因为GIL的存在不能够发挥CPU的多核特性
对于计算密集型任务应该考虑使用多进程
time python3 example22.py
real 0m11.512s
user 0m39.319s
sys 0m0.169s
"""
import concurrent.futures
import math

PRIMES = [
1116281,
1297337,
104395303,
472882027,
533000389,
817504243,
982451653,
112272535095293,
112582705942171,
112272535095293,
115280095190773,
115797848077099,
1099726899285419
] * 5


def is_prime(n):
"""判断素数"""
if n % 2 == 0:
return False

sqrt_n = int(math.floor(math.sqrt(n)))
for i in range(3, sqrt_n + 1, 2):
if n % i == 0:
return False
return True


def main():
"""主函数"""
with concurrent.futures.ProcessPoolExecutor() as executor:
for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)):
print('%d is prime: %s' % (number, prime))


if __name__ == '__main__':
main()
Binary file removed Day31-35/res/andrew-tanenbaum.png
Binary file not shown.
Binary file added Day31-35/res/andrew.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added Day31-35/res/ken_young.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added Day31-35/res/pdp-11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Day31-35/res/rk05.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b74e0de

Please sign in to comment.