本文最后更新于:2025年10月16日 凌晨

Python 今年推出了 3.14 版本,大幅提升了运行速度,加入了自由线程功能,本文记录 python 3.14 和 pypy 的安装配置与使用方法,并记录与 3.10 版本的基础性能比较。

安装

这里使用 Anaconda 安装相关的 Python 环境。

  • Python 3.14
1
conda create -n py314 python==3.14
  • Conda Pypy
1
conda create -n pypy_latest pypy -c https://conda.anaconda.org/conda-forge

当前(2025.10)通过命令安装的 pypy python 版本为 3.9

激活环境并执行:

1
2
3
4
conda activate pypy_latest
pypy -m ensurepip
pypy -mpip install -U pip wheel # to upgrade to the latest versions
pypy -mpip install numpy # for example
  • 最新 Pypy 安装

最新版官方安装:https://pypy.org/download.html

下载后解压,bin 放入系统路径即可使用。

包安装

Pypy

pypy 存在很多python 包冲突,这里记录已知的冲突解决方法

  • opencv-python

事实上部分版本使用 pip 可以直接安装:

1
pypy -mpip install opencv-python

但是安装好的包在 import 时会报错:

1
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

有时也报错 circle import

但是通过 conda 的 conda-forge 安装的话会安全很多

安装方法:

1
conda install -c conda-forge opencv 

性能比较

使用自己编写的全局路径规划算法作测试程序:

Python 版本 运行时间 备注
Python 3.10 0.757s
Python 3.14 0.151s
Pypy 3.9 3.023s
  • 异常记录:Python 3.14 看上去快了很多,但是事实上 Python 3,14 的很多行为和 3.10 相差很多,甚至不太稳定,当前(2025.10)需要谨慎使用
  • Pypy 在非纯 python 的情况下并不具备性能优势

基础性能比较

计算性能

测试代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import time
import numpy as np


if __name__ == '__main__':
time_list = list()

for i in range(3):
start = time.time()

data_num = 3000
sum_value = 0
for i in range(data_num):
for j in range(data_num):
sum_value += (i * j) ** 2


end = time.time()
time_list.append(end - start)
print(f" {i}th result is : {sum_value}, cost time: {end - start}.")

print(f" result is : {sum_value}, cost time: {np.mean(time_list)}.")
Python 版本 Debugging 运行时间 (s) without Debugging 运行时间 (s)
Python 3.8 2.13 1.56
Python 3.10 2.47 1.83
Python 3.11 2.29 1.67
Python 3.14 0.69 0.67
Pypy 3.9 0.06 0.06

结果与 Miguel 的结果一致,在纯 Python 下 3.14 确实快很多,Pypy 更是快到离谱。

参考资料



文章链接:
https://www.zywvvd.com/notes/coding/python/python-version-test-2025/python-version-test-2025/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

2025 Python 版本性能测试
https://www.zywvvd.com/notes/coding/python/python-version-test-2025/python-version-test-2025/
作者
Yiwei Zhang
发布于
2025年10月13日
许可协议