[Python-Dev] Accessing globals without dict lookup

Tim Peters tim.one@comcast.net
Tue, 12 Feb 2002 15:24:47 -0500

> Have we become convinced that these cells need to be Python objects?

No, it's just easier that way.  The existing dict code maps PyObject* to
PyObject*, so we'd have to copy and fiddle *all* of the dict code if a
celldict wants to map to anything other than a PyObject*.

> I must have missed that.  As long as we can keep them simple
> structures, we should be able to avoid individual allocations for
> them.  It seems we have a fixed number of cells for both module
> objects and function objects (regardless of whether they are part of
> the new celldict or the containing function or module), so they can be
> allocated as an array rather than individually.
> So, I must be missing something.

cells don't live in function objects; a function object only has a vector of
pointers *to* cells, and that is indeed a contiguous, fixed-size array.

cells are the values in celldicts, and that's the only place they appear,
and celldicts can grow dynamically (import fred; fred.brandnew = 1).