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) ?