> 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.
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 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. > whether it would actually be more appropriate for a list instead Lists are not immutable, so they fail the criteria. > Do all your tuples have the same length? In an inner context, yes. But in an outer context, no. What I mean by that is that, in my particular case, the number of entries is a hyperparameter. ------- Original Message ------- On Friday, March 11th, 2022 at 2:56 PM, Chris Angelico <ros...@gmail.com> wrote: > On Sat, 12 Mar 2022 at 06:50, wfdc w...@protonmail.com wrote: > > > > You still haven't shown why a namedtuple is wrong for your use-case. > > > > See Christopher Barker's previous reply to you. > > > > Furthermore, namedtuples have fieldnames. Tuples have indices. Tuples are > > conceptually more appropriate if we're dealing with what are supposed to be > > numeric indices into some sequential datastructure, rather than a > > dictionary-like one. > > You keep saying this sort of thing, but you haven't shown us what your > > use-case actually is, and whether it would actually be more > > appropriate for a list instead. > > Do all your tuples have the same length? > > 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/L5BMYZANGKP2FKO2OE3AOJDZEKEOQ4HT/ > > 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/V5YY2SSTL4JUTNAQGQQQQLZSH5572V5L/ Code of Conduct: http://python.org/psf/codeofconduct/