Comments (4)
还是不太一样的, 协程就不需要考虑同步异步的问题了, 因为切换的问题是交给用户自己控制了
from interview_python.
恩,这个地方是我理解错了
参见https://segmentfault.com/a/1190000000663472
和http://www.cnblogs.com/lhfcws/p/4148227.html
from interview_python.
线程确实比协程性能更好。因为线程能利用多核达到真正的并行计算,如果任务设计的好,线程能几乎成倍的提高你的计算能力,说线程性能不好的很多是因为没有设计好导致大量的锁、切换、等待,这些很多都是应用层的问题。而协程因为是非抢占式,所以需要用户自己释放使用权来切换到其他协程,因此同一时间其实只有一个协程拥有运行权,相当于单线程的能力。我们在x360、xbox1和ps4上做游戏的时候,开线程用来做数据加载、解压这种不需要或者很少需要数据同步的任务的时候效率杠杠的,而协程用来处理一些应用层逻辑调度的时候非常方便。官方文档也建议,协程只是为了老代码移植和兼容性,不推荐新代码使用。
from interview_python.
恩, 你说的对,
但是python 里算比较特殊, 因为只能用单核.
你说的官方文档是?
from interview_python.
Related Issues (20)
- 资料有一处错误 HOT 3
- 乐观锁悲观锁 导读链接 挂了 HOT 1
- 乐观锁悲观锁链接挂了,建议改用这个链接:https://my.oschina.net/feixuewuhen/blog/800346
- 和小土刀的笔记一模一样 HOT 2
- 对字符串格式化
- 关于 "23 Python里的拷贝"的疑问
- a
- GIL 部分描述有误 HOT 1
- __new__和__init__的区别 HOT 1
- 编程题 第8题 问题描述不够精确
- Gitbook 的链接看不到里面的内容 HOT 3
- 感觉GET和POST区别的解释有点问题
- 13 关于python的重载 应该是可以通过classmethod实现
- 3 @classmethod 和@statimethod 在子类继承上也有区别
- 交叉链表求焦点,修改了一下后面那个解答是错误的 HOT 1
- 有一部分简书的链接404了 可能需要更新一下超链接
- [名词修改]自省建议改成反射
- 15 中的 __new__ 方法是类方法吧 HOT 2
- 这里面应该有不少答案是由英文翻译过来的,而且是非技术人员翻译,很容易被误导,请注意! HOT 1
- 6.字典推导式中有错误 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interview_python.