[Python-Dev] Fast access to __builtins__

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


> > I don't see the problem.  Typically, C extension modules don't have
> > Python code that runs in their globals, so messing with a C
> > extension's globals from the outside has no bad effect on Python code.
> 
> It happens, though -- for code whose performance is not important,
> e.g. initialization and "resetting" kind of stuff, a PyRun_String can be
> SO much more concise and handier than meticulous expansion of
> basically the same things into tens of lines of C code... since
> "messing from the outside" happens after initialization, and the use
> cases I can easily find are all specifically DURING initialization, it may
> be that this problem is too rare to worry about, but, I'm not so sure.

I think this use case won't have a problem.  The C code has access to the
real dict, so PyRun_String() never knows that it's poking into a
module's globals.  Also this is done during module initialization.

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