Terry J. Reedy added the comment:

What is the purpose in touching fieldnames, either in tuple-izing it or in 
making it private and wrapped with a property. If someone wants to modify it, 
that is up to them. In any case, this change is not germane to the issue and 
could break code, so I would not make it.

wrong_fields could be calculated with
any(k for k in rowdict if k not in self._fieldset)
to stop on the first extra, if any.

That said, in 3.x, replacing

  wrong_fields = <long expression>
  if wrong_fields:
with
  if rowdict.keys() - self._fieldset:
should be even faster because the iteration, which will nearly always go to 
completion, is entirely in C (or whatever).

Does test/text_cvs have tests for DictWriter, both with and without rowdict 
errors? If so, or if added, I would be willing to commit a patch that simply 
added ._fieldset and used it as above for a set difference.

Also, if you have not done so yet, please go to
http://www.python.org/psf/contrib/  and
http://www.python.org/psf/contrib/contrib-form/  new electronic form
and submit a contributor agreement. An '*' will appear after your name here 
when it is processed.

----------
nosy: +terry.reedy
versions: +Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18219>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to