[Python-Dev] Proposal to eliminate PySet_Fini
Josiah Carlson
jcarlson at uci.edu
Fri Jun 30 02:37:20 CEST 2006
"Alexander Belopolsky" <alexander.belopolsky at gmail.com> wrote:
> On 6/29/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> >... dict is more basic, set is just a special case of
> > dict for performance reasons. Also, dict is used to define and implement
> > the language itself, set is "just" a predefined type.
> >
> I guess it can be seen either way, just as a chicken and an egg. Does
> python-3000 still plan to integrate sets and dicts so that a set is a
> view of a dict? That would support the view that a set is more basic
> (dict code will depend on set code but not the other way around).
I don't think that makes sense. I see a basic structure as one that can
be used to implement other structures. A dict can emulate a set, but a
set cannot emulate a dict. Thus, a set is a specialization of a dict
with fewer features than the regular dict.
> If set has better performance than dict (which I have not noticed so
> far), it will be appropriate to use it in the language implementation
> where it can replace a dict. The prime example is the "interned"
> dict.
The performance, I believe, is based on a Python 2.5 optimization
that reduces memory consuption per entry from 12 to 8 bytes per entry.
> > ... It is by design that you can use the dict API everywhere, since
> > dict is part of the language itself. set wasn't designed with such a
> > goal (the same is true for many other types, I would guess).
>
> That's probably the hart of my proposal. I would like to see sets
> usable as a part of the language, or an application that embeds the
> language everywhere where dicts can be used today.
I disagree. You can get everything you need with a dict, and making
sets a part of the language (besides being a builtin type), would
necessarily add more overhead and maintenance to the language for little
gain. If you need set-like functionality, and you need it to not be
finalized, use a dict; it is available today, can do all the same things, and
you don't need to wait at least 1.5 years until Python 2.6 is out.
- Josiah
More information about the Python-Dev
mailing list