Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
流畅的Python(第2版)
by
Luciano Ramalho
April 2023
Intermediate to advanced
769 pages
25h 16m
Chinese
Posts & Telecom Press
Content preview from
流畅的Python(第2版)
636
|
第
21
章
最后,推荐阅读
Bob Nystrom
写的“
What Color Is Your Function?
”一文。这篇文章讨论了
JavaScript
、
Python
、
C#
等语言中常规函数和异步函数
(即协程)不相容的执行模型。内容
剧透:
Nystrom
得出结论
,
Go
语言的做法是正确的,即所有函数的颜色相同。我喜欢
Go
语言的这种做法。但是,我也觉得
Nathaniel
J. Smith
在“
Go statement considered harmful
”
一文中所说的有道理。世间不完美,并发编程始终是难题。
杂谈
一个速度慢的函数差点儿毁掉
uvloop
的基准测试
2016
年,
Yury Selivanov
发布了
uvloop
。这是“一个事件循环,可以直接取代
asyncio
内置的事件循环,速度更快”。当年宣布这个库问世的博客文章提供了基准测试,表现
让人赞叹。他写道:“(
uvloop
)至少比
Node.js
、
gevent
,以及其他
Python
异步框架快
2
倍。基于
uvloop
的
asyncio
,性能接近
Go
程序。”
然而,那篇文章也指出,若想与
Go
语言的性能相当,需要满足两个条件。
1.
配置
Go
语言使用单个线程。这样
Go
语言运行时的行为才与
asyncio
类似:通过
同一个线程中由一个事件循环驱动的多个协程实现并发。
18
2.
使用
Python 3.5
编写代码,而且除了
uvloop
自身,还要使用
httptools
。
Selivanov
使用
aiohttp
(早期使用
asyncio
实现的全功能
HTTP
库之一)对
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
Python高级编程(第2版)
Posts & Telecom Press, Michał Jaworski, Tarek Ziadé
Python语言及其应用(第2版)
Bill Lubanovic
Kafka权威指南(第2版)
Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty
Python贝叶斯分析(第2版)
Posts & Telecom Press, Osvaldo Martin
Publisher Resources
ISBN: 9787115612366