[Python-Dev] Where is PyMarshal_ReadShortFromFile() ?

Tim Peters tim.one@home.com
Fri, 12 Oct 2001 23:56:58 -0400


[James C. Ahlstrom]
> Yes they should be public, because PyMarshal_ReadLongFromFile() is used
> in import.c to read the Python byte code signature MAGIC from a *.pyc
> file.  I need a PyMarshal_ReadShortFromFile() to read zip archives in
> import.c.

There's a finer distinction to be drawn:  "public" doesn't mean "C extern",
it means a conscious decision that if the API in question ever changes, we
promise to bump the Python API version number and so force extension modules
to be recompiled (or at least irritate the user with warnings that they
*should* be recompiled).  IOW, "public" means "anybody in the world can use
this, in or out of the core distribution, and we promise it will never break
silently across releases".  If you use a C extern function like (say)
_PyString_FormatLong outside of the core, and we (say) change the calling
sequence, or even get rid of it, tough luck -- we don't promise anything
about functions (or macros) whose names begin with an underscore (they're
part of "the private C API", C extern or not).

import.c is part of the core, so can use all the private API functions it
likes (and we're responsible for making sure it works across releases no
matter how wildly the private API functions change).