[Python-Dev] Fast access to builtins (original) (raw)

Guido van Rossum guido@python.org
Fri, 28 Mar 2003 07:45:03 -0500


> Frankly, I'm a bit confused by your post. Maybe I don't understand > what you're proposing?

Modules are modules, right? That is, pickle.py and cPickle.so are both represented as module objects at runtime. A C extension can call PyModuleGetDict() on any module. If so, then any extension module can add names to the dict of any Python module. The problem is that modules expose their representation at the C API level (namespace implemented as PyDictObject), so it's difficult to forbid things at the C level.

Oh sure. I don't think it's necessary to forbid things at the C API level in the sense of making it impossible to do. We'll just document that C code shouldn't do that. There's plenty that C code could do but shouldn't because it breaks the world.

I don't expect there will be much C in violation of this prohibition.

--Guido van Rossum (home page: http://www.python.org/~guido/)