这是我在python中的代码:
for post in posts:
ss = get_vector_local(word_list, status)
# ss is a string
if ss is not None:
output_file.writelines(ss + '\n')
但我需要写1GB文件。
我是否需要使用python-C扩展模块重写输出部分以使输出更快?
答案 0 :(得分:1)
解释Linus T.,C基本上是最便携的汇编程序,因此在纯计算中击败python。
另一方面的示例处理I / O,只要python能够足够快地提供I / O缓冲区,与纯C相比,应该只有可忽略的开销。