The fastest way to read input in Python

后端 未结 6 1573
孤街浪徒
孤街浪徒 2020-11-27 07:56

I want to read a huge text file that contains list of lists of integers. Now I\'m doing the following:

G = []
with open(\"test.txt\", \'r\') as f:
    for li         


        
6条回答
  •  悲&欢浪女
    2020-11-27 08:18

    The easiest speedup would be to go for PyPy http://pypy.org/

    The next issue to NOT read the file at all (if possible). Instead process it like a stream.

提交回复
热议问题