[New-bugs-announce] [issue18219] csv.DictWriter is slow when writing files with large number of columns

Mikhail Traskin report at bugs.python.org
Sat Jun 15 07:12:39 CEST 2013


New submission from Mikhail Traskin:

_dict_to_list method of the csv.DictWriter objects created with extrasaction="raise" uses look-up in the list of field names to check if current row has any unknown fields. This results in O(n^2) execution time and is very slow if there are a lot of columns in a CSV file (in hundreds or thousands). Replacing look-up in a list with a look-up in a set solves the issue (see the attached patch).

----------
components: Library (Lib)
files: csvdictwriter.patch
keywords: patch
messages: 191197
nosy: mtraskin
priority: normal
severity: normal
status: open
title: csv.DictWriter is slow when writing files with large number of columns
type: performance
Added file: http://bugs.python.org/file30598/csvdictwriter.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18219>
_______________________________________


More information about the New-bugs-announce mailing list