[Python-Dev] small improvement idea for the CSV module

2019-10-29 Thread Oz Tiram
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-le...@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/


[Python-Dev] Re: small improvement idea for the CSV module

2019-10-30 Thread Oz Tiram
Hi Steve,

Thanks for your reply. While dataclass provide a cleaner API than DictRow
(you can access `row.id` instead of `row["id"]`).
However, dataclass still use the built in `__dict__` instead of
`__slots__`.

```
>>> @dataclass
... class InventoryItem:
... '''Class for keeping track of an item in inventory.'''
... name: str
... unit_price: float
... quantity_on_hand: int = 0
...

>>> cf = InventoryItem("cornflakes", 0.99, 123)
>>> cf
InventoryItem(name='cornflakes', unit_price=0.99, quantity_on_hand=123)
>>> cf.__dict__
{'name': 'cornflakes', 'unit_price': 0.99, 'quantity_on_hand': 123}
```

This means that the users reading large files won't see the suggested
memory improvements.

On the other hand, I'm willing to implement CSVReader classes for both.
`DataClassCSVReader` does offer the
benefit of row instances being mutable, `NamedTupleCSVReader` can be useful
for people leaning toward functional
programming style, where queries on CSV are only meant to find items or
calculate quantities quickly without actually
modifying the rows.

I would be more than happy to know whether such PR would accept.

Best regards
Oz


On Wed, Oct 30, 2019 at 8:39 AM Steve Holden  wrote:

> 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  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-le...@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/
>>
>

-- 


---

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-le...@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/D4SRFILSFXL226473B7KPQ5XFRJCLHQX/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: small improvement idea for the CSV module

2019-10-30 Thread Oz Tiram
Hi Serhiy,
Thanks! Now, I am feeling confused. On the one hand, it's already been
tried 10 years ago. On the other hand, obviously people do wish to have it.
I'm going to send a PR In GitHub. Let's see if a new PR with some
documentation can be appreciated.

Oz

On Wed, Oct 30, 2019, 16:25 Serhiy Storchaka  wrote:

> 29.10.19 22:37, Oz Tiram пише:
> > 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.
>
> See https://bugs.python.org/issue1818
> ___
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@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/H6L74TDMPP7TSVVKQS2VMI4ZVZTTSMUW/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@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/KKWZBZMBGID45XKEXRX6WQWBDJDMQASD/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Thank you Larry Hastings!

2020-10-05 Thread Oz Tiram
Thank you ☺️.
This is what makes python great.



On Mon, Oct 5, 2020, 20:41 Barry Warsaw  wrote:

> They say being a Python Release Manager is a thankless job, so the Python
> Secret Underground (PSU), which emphatically does not exist, hereby
> officially doesn’t thank Larry for his years of diligent service as the
> Python 3.4 and 3.5 release manager.
>
> On the other hand, the Python Steering Council, Python Software
> Foundation, and worldwide Python community, all of which emphatically *do*
> exist, all extend our heartfelt thanks to Larry for his excellent
> stewardship of Python 3.4 and 3.5!
>
> Python 3.4 and 3.5 were both pivotal releases.  While the features of
> these two releases are too numerous to mention here, they introduced such
> staples as:
>
> * asyncio
> * enum
> * pathlib
> * async and await keywords
> * matrix multiplication operators
> * typing and zipapp modules
>
> and so much more.  For details, see:
>
> * https://docs.python.org/3/whatsnew/3.4.html
> * https://docs.python.org/3/whatsnew/3.5.html
>
> Larry’s first official release of 3.4.0a1 was on 2013-08-03 and his last
> Python 3.5.10 release was 2020-09-05.  That’s 7 years of exemplary release
> managing!
>
> Larry, from all of us, and from me personally, thank you so much for your
> invaluable contributions to Python.  Enjoy your retirement!
>
> Cheers,
> -Barry (on behalf of the PSC and PSF)
>
> ___
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@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/QGIHFU64TBYT56K6M5A5LYTYTSVFKHWQ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@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/HHNWLWP7IPL2APS4L2BWFTWGYJCD6HJJ/
Code of Conduct: http://python.org/psf/codeofconduct/