#420 转载:为什么 Python 这么 “慢” 却还这么流行?
Python 2020-07-01来自 Quora,原文标题:Why is Python so popular despite being so slow?
说明:这里谈的 Python,很大程度上说的是 CPython 这个标准实现,而不是 Python 这门语言。
coding in a complicated world
来自 Quora,原文标题:Why is Python so popular despite being so slow?
说明:这里谈的 Python,很大程度上说的是 CPython 这个标准实现,而不是 Python 这门语言。
if-else、for、switch、goto)。struct)的定义与初始化。interface)与类型断言。Dog 吠叫、Bird 飞翔)。go func())。select 语句实现多路复用。sync.Mutex 和 atomic 包(锁与原子操作)。net/http(REST API)、net/url(URL 解析)。encoding/json/xml(序列化/反序列化)、sort/math(常用算法)。os/path/filepath(文件操作)、io/ioutil(批量读写)。html/template(生成动态 HTML)。Gin(轻量级 HTTP 框架)、Echo、Beego。etcd(键值存储)、Consul(服务发现)。database/sql + PostgreSQL/MySQL)。GORM、sqlx。MongoDB + mgo 包)。pprof、trace。log 包、zap 日志库)。-> % ps -ef | grep rsyslogd | grep -Fv grep
syslog 1068 1 0 1月06 ? 00:00:03 /usr/sbin/rsyslogd -n -iNONE
-> % sudo ls -l /proc/1068/fd
总计 0
lr-x------ 1 root root 64 1月 8 16:54 0 -> /dev/null
l-wx------ 1 root root 64 1月 8 16:54 1 -> /dev/null
l-wx------ 1 root root 64 1月 8 16:54 10 -> /var/log/kern.log
l-wx------ 1 root root 64 1月 8 16:54 11 -> /var/log/auth.log
l-wx------ 1 root root 64 1月 8 16:54 2 -> /dev/null
lrwx------ 1 root root 64 1月 6 09:46 3 -> 'socket:[13299]'
lr-x------ 1 root root 64 1月 8 16:54 4 -> /dev/urandom
lrwx------ 1 root root 64 1月 8 16:54 5 -> 'socket:[27825]'
lrwx------ 1 root root 64 1月 8 16:54 6 -> 'socket:[27831]'
lr-x------ 1 root root 64 1月 8 16:54 7 -> /proc/kmsg
lrwx------ 1 root root 64 1月 8 16:54 8 -> 'socket:[22468]'
l-wx------ 1 root root 64 1月 8 16:54 9 -> /var/log/syslog
-> % sudo find /proc/*/fd -ls | grep /var/log/syslog
2551982 0 l-wx------ 1 root root 64 1月 8 16:50 /proc/1068/fd/9 -> /var/log/syslog
-> % ps -fq 1068
UID PID PPID C STIME TTY TIME CMD
syslog 1068 1 0 1月06 ? 00:00:03 /usr/sbin/rsyslogd -n -iNONE
uu 编码是加州大学伯克利分校 1980 年为在邮件中传输二进制文件而设计的一种 B2T(Binary-To-Text)/ B2A(Binary-To-Ascii)编码。
九十年代,MIME 被设计出来并成为国际标准之后,uu 编码就正式退出了历史舞台。
uu 代表 Unix-to-Unix Copy,表示将一个文件从一个 Unix 系统传输到另一个 Unix 系统。
git log --grep=fix: --oneline --after='2018-07-01' --author=markjour
git grep -C3 sign_position $(git rev-list --all)
git log -G'前置'
git log -G'前置' -p | grep '前置' -C5
git log -G'前置' --oneline --name-status
-S<string> --pickaxe-regex 和 -G<regex> 作用相近,
不过 -S 只会列出搜索内容增删的相关信息,也就是所在行修改了,但是搜索内容没有变化的会忽略
https://github.com/chubin/wttr.in
curl wttr.in/wuhan
curl wttr.in/wuhan?lang=zh
curl wttr.in/jiangxia?lang=zh
# 指定日期
curl wttr.in/jiangxia@2020-06-07?lang=zh
View options:
0 # only current weather
1 # current weather + today's forecast
2 # current weather + today's + tomorrow's forecast
A # ignore User-Agent and force ANSI output format (terminal)
F # do not show the "Follow" line
n # narrow version (only day and night)
q # quiet version (no "Weather report" text)
Q # superquiet version (no "Weather report", no city name)
T # switch terminal sequences off (no colors)
指定 view:
# 只看今天的天气
# 不显示颜色
curl "wttr.in/jiangxia?0T&lang=zh"
Tkinter 可以认为是 Python 官方支持的 GUI 框架,接近标准库的地位,样式风格就是极简。
基于 Tcl/Tk。
PyQt Riverbank Computing 提供的第三方 Python 绑定,非常知名。
风险:GPL 协议,并不是和 Qt 一样的 LGPL。也就是说,使用 PyQt 开发的软件必须开源,除非购买商业授权。特别不建议使用。
没有看到 GitHub 仓库。
PySide Qt 官方 Python 绑定,也叫 Qt for Python。
据说当年 Qt 的持有者,Nokia 公司,找 Riverbank Computing 谈 PyQt 的授权问题,没有谈成,因而从新开发了这个项目。
没有 GitHub 仓库,代码可以在 官方 cgit 上看到。
注意:这里就指 pyside2,和更老的 pyside 区分开来。
PyGObject GTK 官方 Python 绑定
原来叫 PyGTK,多好,不知道为什么改成这个名字
https://gitlab.gnome.org/GNOME/pygobject
https://github.com/GNOME/pygobject
gooey 可以快速实现命令行 GUI 化。
pagefile.sys:Windows 的交换(SWAP)文件。默认在 C 盘根目录,和内存一样大,可以在“高级系统设置”中更改其位置和大小。hiberfil.sys:休眠模式系统状态转储文件。一般也会有几个 G。swapfile.sys:Win10 引入,作用和 pagefile.sys 相同,但他的大小可以自动调整。desktop.ini:文件夹配置文件(隐藏文件),用于自定义文件夹的外观和行为。thumbs.db:缩略图缓存文件(隐藏文件),用于加快文件夹中图像文件的显示速度。ntuser.dat:用户配置文件(隐藏文件),包含了用户的注册表设置和个人偏好。boot.ini:启动配置文件,用于指定启动选项和操作系统位置。