タグ

関連タグで絞り込む (0)

  • 関連タグはありません

タグの絞り込みを解除

pythonとsortとpypyに関するishideoのブックマーク (1)

  • PyPyを速くする(1) sort - inamori’s diary

    PyPyは同じソースを動かしてもPythonよりたいてい速いのですが、遅くなることもあります。その対処法がいくつかあるので紹介していきます。 今回はリストのソートです。こんなコードを動かしてみます。 from itertools import * import time def gen_S(): S = 290797 while True: S = S * S % 50515093 yield S def sort_long(N): a = list(islice(gen_S(), N)) t0 = time.clock() a.sort() print time.clock() - t0 N = 10 ** 7 sort_long(N) これを動かすと、Pythonで9秒、PyPyで25秒でした。 これがなぜ遅いかというと、リストに多倍長整数が混じっているからのようです。この要素は大きさ

    PyPyを速くする(1) sort - inamori’s diary
  • 1