See

https://sourcegraph.com/search?q=context:global+lang:python+%5C%5B%5Cs*:%5Cs*%28i%7Cj%7Ck%7Cind%7Cindex%29%5Cs*%5C%5D%5Cs*%5C%2B%5Cs*%5C%28.*%5C%2C%5C%29%5Cs*%5C%2B%5Cs*%5B%5Cw%5C.%5D%2B%5C%5B%5Cs*%28i%7Cj%7Ck%7Cind%7Cindex%29%5Cs*%5C%2B%5Cs*1%5Cs*:%5Cs*%5C%5D&patternType=regexp

and

https://sourcegraph.com/search?q=context:global+lang:python+%3D%5Cs*list%5C%28%5B%5Cw%5C.%5D%2B%5C%29%5Cs*%5Cw%2B%5C%5B%5Cw%2B%5C%5D%5Cs*%3D%5Cs*%5B%5Cw%5C.%5D%2B%5Cs*%5B%5Cw%5C.%5D%2B%5Cs*%3D%5Cs*tuple%5C%28%5Cw%2B%5C%29&patternType=regexp

> Yes, and dataclasses and namedtuples support this concept very nicely. You 
> still haven't shown why neither works.

1. They're less efficient, as Christopher pointed out long ago.

2. They're not sequences, so conceptually the wrong tool for the job.

> it definitely seems like a good use-case for a dataclass.

See above.

> Repeatedly stating that it has to be immutable, has to not be a namedtuple, 
> has to not be a dataclass, and has to have a replace method, doesn't make it 
> true.

See above.

------- Original Message -------

On Monday, March 14th, 2022 at 8:30 AM, Chris Angelico <ros...@gmail.com> wrote:

> On Sat, 12 Mar 2022 at 07:38, wfdc w...@protonmail.com wrote:
>
> > > you haven't shown us what your use-case actually is
> >
> > Any use-case where you'd want to modify an entry of an immutable sequence.
>
> That doesn't answer the question any more than your original code
>
> does. You're still starting with the assumption that you want to use a
>
> tuple, and using that as proof that you need to use a tuple.
>
> Show us your ACTUAL use case, your actual code, and why you can't use
>
> either a list or a namedtuple. Stop assuming that you are correct
>
> before you begin, because we don't agree that a tuple is necessary.
>
> You have not shown us any code, only made this repeated assertion and
>
> then wondered why we don't believe you.
>
> > Modifying an immutable datastructure is not a contradictory statement. In 
> > fact, there's a whole literature on it. See
> >
> > https://en.wikipedia.org/wiki/Purely_functional_data_structure
> >
> > https://en.wikipedia.org/wiki/Persistent_data_structure
>
> Yes, and dataclasses and namedtuples support this concept very nicely.
>
> You still haven't shown why neither works.
>
> > As Marco Sulla pointed, out, "Performance apart, this will allow you to 
> > code in functional style more easily."
> >
> > namedtuple's ._replace method is an existing example (as is record updating 
> > in Haskell, which is a purely functional language, with the attending 
> > benefits of immutability).
> >
> > For me specifically, my latest use-case is in a game-theoretic setting 
> > where the tuple represents a strategy profile. But the details of that 
> > would take us far beyond the scope of the discussion.
>
> I don't understand how a strategy profile has to be a tuple. In fact,
>
> particularly since you're wanting to replace one part of it, it
>
> definitely seems like a good use-case for a dataclass.
>
> > > whether it would actually be more appropriate for a list instead
> >
> > Lists are not immutable, so they fail the criteria.
>
> Why?
>
> Do you see how you are still failing to show any actual code, and thus
>
> any actual demonstration of why a tuple is necessary?
>
> Repeatedly stating that it has to be immutable, has to not be a
>
> namedtuple, has to not be a dataclass, and has to have a replace
>
> method, doesn't make it true.
>
> ChrisA
>
> _______________________________________________
>
> 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 
> https://mail.python.org/archives/list/python-ideas@python.org/message/6MZTLI4I42ZEDJATKM5WDYHMSNEOW6IH/
>
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
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 
https://mail.python.org/archives/list/python-ideas@python.org/message/VKCBA6CM3YTW4F6PPJIPEALIZI6FZUGE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to