In dataclasses, support for __slots__ is being added in 3.10. Adding optional
support for iteration would be easy.
--
Eric V. Smith
> On Jul 28, 2021, at 7:29 PM, Paul Bryan wrote:
>
>
> I'm with you; since dataclasses were introduced, namedtuple has not see any
> use from me, though none
I like this idea! It's true that deprecating the namedtuple we lose important
semantics of order - however, if its use as a weaker dataclass is explicitly
discouraged in the documentation, then much of the problem (i.e., people that
want to have a simple data object use two incompatible things d
I frequently use each of namedtuples and data classes in contexts where the
other one would not be appropriate. Yes, I also sometimes use an object
where either would serve... In those cases, mostly SimpleNamespace would
likewise be fine. So would a one line class definition.
On Wed, Jul 28, 2021,
On Thu, Jul 29, 2021 at 10:00 AM wrote:
>
> I'm with you on the backwards-compatibility front. Changing Python fast and
> for no particular reason incurs a big cost. Is the reason good enough to
> justify removing a chunk of the interface? Good question.
>
Answer: Almost never. Case in point:
>From https://death.andgravity.com/namedtuples linked to above by Titus:
> pairs of things, like HTTP headers (a dict is not always appropriate,
since
> the same header can appear more than once, and the order does matter in
some cases)
To me, this is a perfect case of behavior that namedtuples a
I'm with you on the backwards-compatibility front. Changing Python fast and for
no particular reason incurs a big cost. Is the reason good enough to justify
removing a chunk of the interface? Good question.
To your dict argument: if there was a native Pythonic way to make a frozen
list, what wo
It's not actually that, although that's a good point you are making. I found
myself using both of them not because one is more useful in certain cases and
the other in others in small and niche ways. Both of the times I just used the
latest one that came to mind. The fact that two different clas
I've thing I still use NamedTuple for is when I want type safe
heterogeneous iterable unpacking, which is only possible for tuples (and
NamedTuple) eg I'd like to be able to express both:
tx, rx = trio.MemoryChanel[int]()
And:
with trio.MemoryChannel[int]() as channel:
n.start_soon(worker, c
On Thu, Jul 29, 2021 at 9:37 AM wrote:
>
> I was writing some code the other day, and it needed a quick-and-dirty data
> structure definition for a set of related variables. I looked back at other
> code to try be consistent, and found that I used dataclasses in some parts
> and namedtuples in
I was writing some code the other day, and it needed a quick-and-dirty data
structure definition for a set of related variables. I looked back at other
code to try be consistent, and found that I used dataclasses in some parts and
namedtuples in others. Both seemed the right thing to do at the t
On Thu, Jul 29, 2021 at 9:28 AM Paul Bryan wrote:
>
> I'm with you; since dataclasses were introduced, namedtuple has not see any
> use from me, though none of my uses have demanded ultra-high efficiency
> either.
>
> I wonder how many users are currently relying on namedtuple __getitem__
> sem
I'm with you; since dataclasses were introduced, namedtuple has not see
any use from me, though none of my uses have demanded ultra-high
efficiency either.
I wonder how many users are currently relying on namedtuple __getitem__
semantics though. that's functionality dataclasses do not (currently)
Hi, I ran across this nice article a few days ago -
https://death.andgravity.com/namedtuples
which provides some answers as to why you might consider using named tuples.
best,
—titus
> On Jul 28, 2021, at 3:22 PM, pa...@lexyr.com wrote:
>
> [Migrating the discussion from https://bugs.python.or
On Thu, Jul 29, 2021 at 9:07 AM wrote:
>
> [Migrating the discussion from https://bugs.python.org/issue44768.]
>
> PEP 20 says:
>
> > There should be one-- and preferably only one --obvious way to do it.
>
> There are two ways to create a simple named type to store data:
> collections.namedtuple
[Migrating the discussion from https://bugs.python.org/issue44768.]
PEP 20 says:
> There should be one-- and preferably only one --obvious way to do it.
There are two ways to create a simple named type to store data:
collections.namedtuple and dataclasses.dataclass. I propose deprecating
named
Ahh, I see, yes, that actually makes a lot of sense.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
I suggested this before in some typing meetup, but there are a few problems
with it. One is that annotating arguments as "list" or "dict" is often the
wrong thing to do: instead, people should use broader, immutable types like
Iterable, Sequence, or Mapping, to avoid variance problems (
https://myp
17 matches
Mail list logo