リストに要素を追加する処理速度の比較 前提 処理速度の比較として、Pythonの公式実装であるCPythonと、PythonのPythonによるJITコンパイラ実装であるPyPyの実行時間について比較しました。 Pythonのリスト内包表記で使った以下の3つの関数に対して、Pythonで実行時間を計測する方法 その1で定義したデコレータを用いました。 評価対象の関数 # 1. testfunc1: 空リストを用意してappend @time def testfunc1(rangelist): templist = [] for temp in rangelist: templist.append(temp) # 2. testfunc2: 1+appendをオブジェクト化 @time def testfunc2(rangelist): templist = [] append = temp
