On Wed, Oct 30, 2019 at 11:55 PM Oz Tiram wrote:
>
> 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__`.
>
> This means that the
On 29Oct2019 21:37, Oz Tiram wrote:
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
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 S
On 10/30/2019 02:53 AM, Steve Holden wrote:
If using a dictionary but still requiring attribute access, techniques such as
those used at https://github.com/holdenweb/hw can be used to simply client code.
Unless I'm missing something, that doesn't have the memory improvement that
namedtuples
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
On Wed, Oct 30, 2019, 09:43 Steve Holden wrote:
> Since 3.7 it may be that dataclasses offer a cleaner implementation of the
> functionality you suggest.
>
Actually, IMO in this case it would be more useful and fitting to use
namedtuples rather than dataclasses, since CSV rows are naturally
tuple
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 i
If using a dictionary but still requiring attribute access, techniques such
as those used at https://github.com/holdenweb/hw can be used to simply
client code.
Kind regards,
Steve Holden
On Wed, Oct 30, 2019 at 11:15 AM Oz Tiram wrote:
> Hi Steve,
>
> Thanks for your reply. While dataclass pro
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,
Ste