Re: write() vs. writelines()

2006-05-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gregory Petrosyan wrote: > Thanks for your reply. I understand this fact, but I wonder why > writelines() works slowly -- I think C code can be optimised to work > faster than Python one. Is it correct that writelines(...) is just a > shorthand for > > for ch in ...: >

Re: write() vs. writelines()

2006-05-26 Thread Gregory Petrosyan
Thanks for your reply. I understand this fact, but I wonder why writelines() works slowly -- I think C code can be optimised to work faster than Python one. Is it correct that writelines(...) is just a shorthand for for ch in ...: file.write(ch) ? -- http://mail.python.org/mailman/listinfo/

Re: write() vs. writelines()

2006-05-26 Thread Fredrik Lundh
Gregory Petrosyan wrote: > My question is: why write(''.join(...)) works slowly than > writelines(...)? Here's the code: the first copies all the substring to a single string large enough to hold all the data, before handing it over to the file object, while the second just writes the substring