Python 2 namespace change? (was Re: [Python-Dev] Changing existing class instances)

Tim Peters tim_one@email.msn.com
Sat, 22 Jan 2000 18:18:11 -0500


[Jim Fulton]
> ...
> A change to the way that namespaces are handled
> could make this work and have a number of other benefits,
> like global name usage without namespace lookups.
>
> I've suggested this to Guido in the past.  His
> reasonable response is that this would be too big a
> change for Python 1. Maybe this is something to consider
> for Python 2?
>
> The basic idea (borrowed from Smalltalk) is to have a kind
> of dictionary that is a collection of "association"
> objects.  An association object is simply a pairing of a
> name with a value. Association objects can be shared among
> multiple namespaces.

Jim, I've been intrigued by this idea for all the years you've been
suggesting it <wink>, but I've never understood what it is you're proposing!
This is the Python-Dev list, so feel encouraged to present it in concrete
implementation terms instead of ambiguous English.  Or maybe an interface?

interface a_kind_of_dictionary_that_is_a_collection_of_\
              association_objects:
    # ??? beats me ...

Or maybe as a C struct?  For example, is "an association object" a (char*,
PyObject*) pair?

Does this kind of dictionary have keys?  If so, of what type?  What type are
the values?  Best I can make sense of the above, the values are "association
objects", each of which contains a name and a value, and a key is maybe a
duplicate of the name in the association object to which it maps.  "A name"
may or may not be a string -- I can't tell.  Or maybe by "dictionary" you
didn't intend Python's current meaning for that word at all.  I assume "a
value" is a PyObject*.  The whole thrust *appears* to be to get names to map
to a PyObject** instead of PyObject*, but if that's the ticket I don't know
what association objeects have to do with it.

> An import like:
>
>   from foo import spam
>
> would copy the association between the name 'foo' and a
> value from module 'spam' into the current module.

Where does the idea that 'spam' is a *module* here come from?  It doesn't
make sense to me, and I'm so lost I'll spare everyone my further confusions
<wink>.

suspecting-the-last-actually-doesn't-make-any-sense<wink>-ly
    y'rs  - tim