[Python-Dev] #include "Python.h"

Eli Bendersky eliben at gmail.com
Sun Jan 29 20:05:33 CET 2012

On Sun, Jan 29, 2012 at 17:34, Andrea Crotti <andrea.crotti.0 at gmail.com> wrote:
> I have a newbie question about CPython.
> Looking at the C code I noted that for example in tupleobject.c there is
> only one include
> #include "Python.h"
> Python.h actually includes everything as far as I can I see so:
> - it's very hard with a not-enough smart editor to find out where the
>  not-locally defined symbols are actually defined (well sure that is
>  not a problem for most of the people)

Hi Andrea,

Not sure what you mean by "not-enough smart editor". Dismissing IDEs
for the moment (which by your classifications are probably "smart
enough"), Python's source code (including headers included in
Python.h) is readily navigable with Emacs or Vim using ctags, which is
very easy to set up. Declarations are then easily found.

Even if you forgo such features of the editor, grepping (or source
specific greppers like ack or pss) also works fine most of the time.

> - if all the files include python.h, doesn't it generate very big object
>  files? Or is it not a problem since they are stripped out after?

Header files usually don't affect object file size. Unless something
very fishy is going on (and this is not the case for headers included
from Python.h, AFAIK) headers only contain declarations which don't
affect code size. They may affect compilation time, but that's not a
bit problem for Python's code base which is very fast to compile.


More information about the Python-Dev mailing list