astral-sh发布的musl和gnu版本standalone python 性能比较

musl版本standalone python在wsl默认的ubuntu中无法运行。说是找不到文件,其实文件就在那里

复制代码
C:\d>wget https://mirror.nju.edu.cn/github-release/astral-sh/python-build-standalone/LatestRelease/cpython-3.14.5rc1%2B20260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz


2026-05-06 19:29:58 (40.0 MB/s) - 'cpython-3.14.5rc1+20260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz' saved [28819140/28819140]


C:\d>wsl
root@DESKTOP-59T6U68:/mnt/c/d# mkdir tpy3145
root@DESKTOP-59T6U68:/mnt/c/d# cd  tpy3145
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# tar xf ../cpython-3.14.5rc1+20260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# cat /etc/issue
Ubuntu 22.04.5 LTS \n \l

root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# time python/bin/python ../primes.py
-bash: python/bin/python: No such file or directory

real    0m0.018s
user    0m0.001s
sys     0m0.004s
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# ls -l  python/bin/
total 21464
lrwxrwxrwx 1 root root        8 Jan  1  2024 idle3 -> idle3.14
-rwxrwxrwx 1 root root      156 Jan  1  2024 idle3.14
-rwxrwxrwx 1 root root      234 Jan  1  2024 pip
-rwxrwxrwx 1 root root      234 Jan  1  2024 pip3
-rwxrwxrwx 1 root root      234 Jan  1  2024 pip3.14
lrwxrwxrwx 1 root root        9 Jan  1  2024 pydoc3 -> pydoc3.14
-rwxrwxrwx 1 root root      141 Jan  1  2024 pydoc3.14
lrwxrwxrwx 1 root root       10 Jan  1  2024 python -> python3.14
lrwxrwxrwx 1 root root       10 Jan  1  2024 python3 -> python3.14
lrwxrwxrwx 1 root root       17 Jan  1  2024 python3-config -> python3.14-config
-rwxrwxrwx 1 root root 21971912 Jan  1  2024 python3.14
-rwxrwxrwx 1 root root     3198 Jan  1  2024 python3.14-config
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# rm -fr python
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145#
logout

改用gnu版本standalone python,一切正常。

复制代码
C:\d>wget https://mirror.nju.edu.cn/github-release/astral-sh/python-build-standalone/LatestRelease/cpython-3.14.5rc1%2B20260504-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz


2026-05-06 19:36:13 (19.9 MB/s) - 'cpython-3.14.5rc1+20260504-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz' saved [35924552/35924552]


C:\d>wsl

root@DESKTOP-59T6U68:/mnt/c/d# cd tpy3145
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# tar xf ../cpython-3.14.5rc1+20260504-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# time python/bin/python ../primes.py

real    0m1.982s
user    0m1.623s
sys     0m0.226s

在网上查询得知,Alpine版本Linux自带musl,刚好机器上有个alpine docker容器。

复制代码
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# docker container list -a|grep Alpine
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# docker container list -a|grep pine
9d3934fdf92d  m.daocloud.io/docker.io/alpine:latest                  /bin/sh               16 months ago  Exited (0) 16 months ago                                                    alp2
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# docker start alp2
alp2
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# docker exec -it alp2 bash
Error: executable file `bash` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
root@DESKTOP-59T6U68:/mnt/c/d/tpy3145# docker exec -it alp2 sh
/ # cd /par
sh: cd: can't cd to /par: No such file or directory

/ # wget https://mirror.nju.edu.cn/github-release/astral-sh/python-build-standalone/LatestRelease/cpython-3.14.5rc1%2B20
260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz
Connecting to mirror.nju.edu.cn (210.28.130.3:443)
saving to 'cpython-3.14.5rc1%2B20260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz'
cpython-3.14.5rc1%2B 100% |************************************************************************| 27.4M  0:00:00 ETA
'cpython-3.14.5rc1%2B20260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz' saved
/ # cd /tmp
/tmp # tar xf ../cpython-3.14.5rc1%2B20260504-x86_64-unknown-linux-musl-install_only_stripped.tar.gz
/tmp # vi
/tmp # cat /etc/issue
Welcome to Alpine Linux 3.21
Kernel \r on an \m (\l)

/tmp # time python/bin/python primes.py
real    0m 2.19s
user    0m 1.97s
sys     0m 0.22s

果然,musl版本standalone python可以在alpine中执行,速度的确比版本号相同的gnu python版本要慢一些。

相关推荐
吃好睡好便好1 天前
提取矩阵某一行或某一列元素
开发语言·人工智能·线性代数·算法·matlab·矩阵
小江的记录本1 天前
【JVM虚拟机】垃圾回收GC:四种引用类型:强引用、软引用、弱引用、虚引用(附《思维导图》+《面试高频考点清单》)
java·jvm·spring boot·后端·python·spring·面试
APIshop1 天前
Python 获取 1688 商品采集 API 接口 | 工厂货源自动化对接商品信息 | 无需选品
运维·python·自动化
deepin_sir1 天前
10 - 函数
开发语言·python
z落落1 天前
C#String字符串
开发语言·c#·php
猫头虎-前端技术1 天前
JS 作用域与闭包:从变量提升到闭包陷阱的超详细解析
开发语言·javascript·云计算·bootstrap·ecmascript·openstack·perl
charlee441 天前
《GIS基础原理与技术实践》配套案例(Python版)
python·conda·numpy·gis·环境配置
枫叶林FYL1 天前
项目十:事件溯源仓储管理系统(WMS)仿真实现
开发语言·python
繁华落尽,倾城殇?1 天前
[C++11] : atomic,nullptr,default/delete,enum class
开发语言·c++·c++11·nullptr·atomic·enum class·default/delete
01_ice1 天前
C语言数据在内存中的存储
c语言·开发语言