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

Jim Fulton jim@digicool.com
Thu, 03 Feb 2000 10:39:50 -0500


Tim Peters wrote:
> 
> [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?

I just responded to Guido in a bit more detail. Hopefully, this will
be of sufficient clarity. If not, then I'll be happy to work up
a Python demonstration.

> Does this kind of dictionary have keys? 

Yes.

> If so, of what type? 

Whatever you want. Just like a dictionary.

> What type are
> the values? 

ditto.

> 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. 

Sorry. See my reply to Guido and let me know if I'm still being
too vague.

> 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? 

From my lack of careful typing. Sorry. let me try again:

An import like:

   from foo import spam

would copy the association between the name 'spam' and a
value from module 'foo' into the current module.

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.