[Python-Dev] Structural cleanups to the main CPython repo

Nick Coghlan ncoghlan at gmail.com
Tue May 28 15:07:37 CEST 2013

On Tue, May 28, 2013 at 10:31 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Le Tue, 28 May 2013 22:15:25 +1000,
> Nick Coghlan <ncoghlan at gmail.com> a écrit :
>> I have a feature branch where I'm intermittently working on the
>> bootstrapping changes described in PEP 432.
>> As part of those changes, I've cleaned up a few aspects of the repo
>> layout:
>> * moved the main executable source file from Modules to a separate
>> Apps directory
> Sounds fine (I don't like "Apps" much, but hey :-)).

Unfortunately, I don't know any other short word for "things with main
functions that we ship to end users" :)

>> * moved the _freezeimportlib and _testembed source files from Modules
>> to a separate Tools directory
> Well, they should probably go to Apps too, no?

I wanted to split out "part of the build/test infrastructure" from
"shipped to end users", but I could also live with a simple "Bin"
directory that contained both kinds of executable.

>> * split the monster pythonrun.h/c pair into 3 separate header/impl
>> pairs:
>>    * bootstrap.h/bootstrap.c
>>    * shutdown.h/shutdown.c
>>    * pythonrun.h/pythonrun.c
> I don't think separating bootstrap from shutdown is a good idea. They
> are quite closely related since one undoes what the other did (and they
> may also use shared private functions or data).

It was deliberate - a big part of PEP 432 is making sure that all the
interpreter state lives *in* the interpreter state (as part of the
config struct). Splitting the two into separate compilation modules
makes it possible to ensure that all communication goes via the
interpreter configuration (statics in other modules are still a
problem, but also mostly out of scope for PEP 432).

I *really* want to get us to clean phase separation of "the
interpreter is starting up", "the interpreter is running normally" and
"the interpreter is shutting down". I found that to be incredibly
difficult to do when they were all intermixed in one file, which is
why I decided to enlist the compiler's help by separating them.

> I don't know what goes
> in the remaining "pythonrun.c", could you detail a bit?

While they have some of the PEP 432 changes in them, the header files
in the branch give the general flavour of the separation:

Bootstrap is mostly get/init type functions:

Pythonrun is mostly PyRun_*, PyParser_*, Py_Compile* and a few other
odds and ends:

Shutdown covers the various finalisers, atexit handling, etc:


More information about the Python-Dev mailing list