[Python-Dev] from tuples to immutable dicts
Armin Rigo
arigo@tunes.org
Fri, 29 Nov 2002 03:50:43 -0800 (PST)
Hello Martin,
On Sun, Nov 24, 2002 at 06:10:54PM +0100, Martin v. Loewis wrote:
> > point = tuple(5, 6, color=RED, visible=False)
>
> I have to problems imagining such an extension:
>
> 1. I'm not sure this would be useful.
> 2. I can't imagine how to implement it, without compromising performance
> for tuples.
By introducing a subtype of tuple, just as you do in Python. By the
way, doing it in Python is a nice thing, but then we end up with two
ways of making this kind of small structures: one easily available in
Python but not in C, and one (structseq) for C. Having a C-based
implementation of tuple-with-immutable-dict would unify the two. But
well, I realize that I'm getting stuck with minor things here.
An example that comes in mind where a C-based immutable dict would be
handy is to implement table-based jumps in the bytecode (for switches),
but again this discussion drifted in incompatible directions as we need
non-string keys for this.
Let's just forget it all.
Armin