dict type?

Seth Nickell seth@gnome.org
13 Oct 2003 15:54:20 -0700


On Sun, 2003-10-12 at 18:06, Malcolm Tredinnick wrote:
> On Mon, 2003-10-13 at 07:34, Seth Nickell wrote:
> > On Sat, 2003-10-11 at 15:22, Havoc Pennington wrote:
> > > Hi,
> > > 
> > > Questioning the dict type. A method signature like this:
> > > 
> > >  foo (array<string> keys, array<int> values)
> > > 
> > > gives you equivalent performance and data transfer as the dict type,
> > > except that the values have homogeneous type.
> > > 
> > > Perhaps we should have an "any"/variant type:
> > 
> > >From the python viewpoint, a variant type might be nice to have
> > anyway... but I imagine that could be a PITA for C/C++ developers?
> > 
> > >  foo (array<string> keys, array<variant> values)
> > > 
> > > Would that be more useful and involve less code than
> > > the dict?
> > 
> > Dicts should map quite nicely to hashtables, which I would assume is a
> > common element in most programming systems. Or am I misunderstanding
> > something?
> 
> Except that you rapidly end up having to use GValues for the values in
> GLib and whatever the KDE equivalent is over in that camp because you
> need to track the type of the keys. Unless you only allow dictionaries
> with homogeneous values. I think that is what Havoc was trying to avoid
> (the small, tiny, miniscule, itsty-bitsty annoyance of having to deal
> with GValues). Personally, I don't see the GValue thing as a huge
> problem providing people use it rationally (i.e. everything should not
> be a dictionary; only use dictionaries when you need to, etc).

GValues are something of a PITA. I think homogenously typed dictionaries
is probably the norm in real world usage anyway.

-Seth