2
3

More than 1 year has passed since last update.

Python3.11がどれくらい高速化したのか

Posted at

はじめに

Pythonといえば人口の多さとライブラリの豊富さと情報の多さが強みで
初心者でも簡単に実行できるしWebフレームワークから機械学習までなんでもOKな万能言語

ただひとつ問題点を上げるなら実行速度がナメクジ
C言語もこれにはニッコリ

ところが今回の3.11ではこれが従来比平均1.25倍らしい
すげえ

さっそく試してみた

Pythonで重たい処理といえばforループとListへのappendだと思ってます
なので適当に100万回forループさせて処理速度を計測してみました

import time

s = time.time()
l = []
for i in range(1000000):
    l.append(i)

print(time.time() - s )

比較したのはPython3.10
それぞれ10回実行した結果とその平均が下記

3.10 3.11
1 0.151611089706420 0.110505104064941
2 0.127127647399902 0.110261678695678
3 0.165858030319213 0.109783649444580
4 0.134609222412109 0.126979351043701
5 0.142301082611083 0.126281976699829
6 0.141349554061889 0.109888315200805
7 0.126144647598266 0.109980344772338
8 0.157423019409179 0.121222496032714
9 0.125299692153930 0.115431547164916
10 0.125424385070800 0.125715732574462
平均 0.139714837074279 0.116605019569396

うん、多分1割くらい高速化したと思います

キャッシュとかよくわからんですが

あと3.11ではエラーのときの強調表示(^^^^)が出るようになったっぽいです

Traceback (most recent call last):
  File "C:\Users\test\test.py", line 2, in <module>
    print(fuga)
          ^^^^
NameError: name 'fuga' is not defined

おまけ

ところでWindowsのPythonってどこからインストールしてますか?
Pythonの公式サイト??
私はMicrosoftStoreからワンクリックでインスコしてるのですが、これって公式で配布されてるのと違いってあるのだろうか?
image.png

参考

Python3.11における変更点の詳しいことは安定のGIGAZINEがまとめていました
https://gigazine.net/news/20221026-python-3-11-released/

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3