Is it possible to speed-up python IO?

后端 未结 8 966

Consider this python program:

import sys

lc = 0
for line in open(sys.argv[1]):
    lc = lc + 1

print lc, sys.argv[1]

Running it on my 6GB

相关标签:
8条回答
  • 2020-12-16 16:44

    Note that Python I/O is implemented in C, so there is not much luck speeding it up further.

    0 讨论(0)
  • 2020-12-16 16:45

    If you assume that a disk can read 60MB/s you'd need 6000 / 60 = 100 seconds, which is 1 minute 40 seconds. I don't think that you can get any faster because the disk is the bottleneck.

    0 讨论(0)
提交回复
热议问题