should writing Unicode files be so slow
solipsis at pitrou.net
Sat Mar 20 01:19:07 CET 2010
Le Fri, 19 Mar 2010 17:18:17 +0000, djc a écrit :
> with open(filename, 'rU') as tabfile: to
> with codecs.open(filename, 'rU', 'utf-8', 'backslashreplace') as
> with open(outfile, 'wt') as out_part: to
> with codecs.open(outfile, 'w', 'utf-8') as out_part:
> causes a program that runs in
> 43 seconds to take 4 minutes to process the same data.
codecs.open() (and the object it returns) is slow as it is written in
Accelerated reading and writing of unicode files is available in Python
2.7 and 3.1, using the new `io` module.
More information about the Python-list