Since 3.7 it may be that dataclasses offer a cleaner implementation of the functionality you suggest. It shouldn't be too difficult to produce code that uses dataclasses in 3.7+ but falls back to namedtuples when necessary. You may wish to consider such an implementation strategy.

Best wishes,
Steve Holden


On Tue, Oct 29, 2019 at 10:59 PM Oz Tiram <oz.tiram@gmail.com> wrote:
Hello Python-devs,

The csv module is probably heavily utilized by newcomers to Python, being a very popular data exchange format.
Although, there are better tools for processing tabular data like SQLite, or Pandas, I suspect this is still a very popular
module.
There are many examples floating around how one can read and process CSV with the csv module.
Quite a few tutorials show how to use namedtuple to gain memory saving and speed, over the DictReader.
Python's own documentation has got a recipe in the collections modules[1]
Hence, I was wondering why not go the extra step and add a new class to the CSV module NamedTupleReader?
This class would do a good service for Python's users, especially newcomers who are still not aware of
modules like the collections module.
Would someone be willing to sponsor and review such a PR from me?
As a smaller change, we could simply add a link from the CSV module's documentation to the recipe in the collections module.
What do you think?

Best regards
Oz

[1]: https://docs.python.org/3/library/collections.html?highlight=namedtuple%20csv#collections.namedtuple

---
Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/GRPUTYZOPWTTU532CKZOHCTRSHNFKE2M/
Code of Conduct: http://python.org/psf/codeofconduct/