由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Python里边file writer的问题
相关主题
does the system guarantee this? (转载)请教个C++问题
A question related to pipe问个python读取大文件的问题
multi-thread 一问,请问如何恢复正常的IO?
OpenGL能否方便实现自定义图形的移动,擦除和分层显示?C++ ofstream binary output slow
新人5个包子请教问题,redhat读写文件的内存问题 (转载)URL questions
问一个vim的问题【贴图】这个人的Emacs + GDB 是怎么做出来的? (转载)
为什么redbox比netflix好用的多?关于C C++ 和java的文件读写问题
How to call python_function(class param, char *buf) from c++emacs里面有没有快捷建能交换2个窗口的内容? (转载)
相关话题的讨论汇总
话题: buffer话题: file话题: buffered话题: means话题: python
进入Programming版参与讨论
1 (共1页)
e*********6
发帖数: 3453
1
如果循环里有write file,会不会显著影响速度.
例如:
file = open(name, 'w')
i = 0
while (True) :
file.write(str(i))
i += 1
if (i == 1000000):
break
每次循环,都有一个write,但是只有最后一个版本的write是真正输出,请问这种情况
,disk access有多少次?是仅仅只有最后一次真正写到硬盘上,其他时候都是写在
cache上或者仅仅是file改个指针?还是每次都要往硬盘上写?
M*P
发帖数: 6456
2
印象中是有个buffer,那个buffer多大不记得了。

【在 e*********6 的大作中提到】
: 如果循环里有write file,会不会显著影响速度.
: 例如:
: file = open(name, 'w')
: i = 0
: while (True) :
: file.write(str(i))
: i += 1
: if (i == 1000000):
: break
: 每次循环,都有一个write,但是只有最后一个版本的write是真正输出,请问这种情况

j******o
发帖数: 4219
3
没有参数的话,用系统默认的buffer大小。
The optional buffering argument specifies the file’s desired buffer size: 0
means unbuffered, 1 means line buffered, any other positive value means use
a buffer of (approximately) that size. A negative buffering means to use
the system default, which is usually line buffered for tty devices and fully
buffered for other files. If omitted, the system default is used.
j********x
发帖数: 2330
4
os都有buffer,你以为这么简单的case能想不到?。。。
d******e
发帖数: 2265
5
就1m行,几秒钟的事情。这种性能问题用python就不要考虑了

【在 e*********6 的大作中提到】
: 如果循环里有write file,会不会显著影响速度.
: 例如:
: file = open(name, 'w')
: i = 0
: while (True) :
: file.write(str(i))
: i += 1
: if (i == 1000000):
: break
: 每次循环,都有一个write,但是只有最后一个版本的write是真正输出,请问这种情况

e*********6
发帖数: 3453
6
如果循环里有write file,会不会显著影响速度.
例如:
file = open(name, 'w')
i = 0
while (True) :
file.write(str(i))
i += 1
if (i == 1000000):
break
每次循环,都有一个write,但是只有最后一个版本的write是真正输出,请问这种情况
,disk access有多少次?是仅仅只有最后一次真正写到硬盘上,其他时候都是写在
cache上或者仅仅是file改个指针?还是每次都要往硬盘上写?
M*P
发帖数: 6456
7
印象中是有个buffer,那个buffer多大不记得了。

【在 e*********6 的大作中提到】
: 如果循环里有write file,会不会显著影响速度.
: 例如:
: file = open(name, 'w')
: i = 0
: while (True) :
: file.write(str(i))
: i += 1
: if (i == 1000000):
: break
: 每次循环,都有一个write,但是只有最后一个版本的write是真正输出,请问这种情况

j******o
发帖数: 4219
8
没有参数的话,用系统默认的buffer大小。
The optional buffering argument specifies the file’s desired buffer size: 0
means unbuffered, 1 means line buffered, any other positive value means use
a buffer of (approximately) that size. A negative buffering means to use
the system default, which is usually line buffered for tty devices and fully
buffered for other files. If omitted, the system default is used.
j********x
发帖数: 2330
9
os都有buffer,你以为这么简单的case能想不到?。。。
d******e
发帖数: 2265
10
就1m行,几秒钟的事情。这种性能问题用python就不要考虑了

【在 e*********6 的大作中提到】
: 如果循环里有write file,会不会显著影响速度.
: 例如:
: file = open(name, 'w')
: i = 0
: while (True) :
: file.write(str(i))
: i += 1
: if (i == 1000000):
: break
: 每次循环,都有一个write,但是只有最后一个版本的write是真正输出,请问这种情况

w*****e
发帖数: 721
11
In python 3:
>>> print(io.DEFAULT_BUFFER_SIZE)
8192
1 (共1页)
进入Programming版参与讨论
相关主题
emacs里面有没有快捷建能交换2个窗口的内容? (转载)新人5个包子请教问题,redhat读写文件的内存问题 (转载)
ask a simple question about int pointer.问一个vim的问题
如何动态分配内存来存储输入的不定长的字符串,char not string类型的为什么redbox比netflix好用的多?
如何循环播放一个mp3文件中的某一段?How to call python_function(class param, char *buf) from c++
does the system guarantee this? (转载)请教个C++问题
A question related to pipe问个python读取大文件的问题
multi-thread 一问,请问如何恢复正常的IO?
OpenGL能否方便实现自定义图形的移动,擦除和分层显示?C++ ofstream binary output slow
相关话题的讨论汇总
话题: buffer话题: file话题: buffered话题: means话题: python