[Python-Dev] What is the difference between Py_BUILD_CORE and Py_BUILD_CORE_BUILTIN?

Victor Stinner vstinner at redhat.com
Tue Nov 6 10:09:09 EST 2018


Hi,

I'm trying to cleanup the Python C API, especially strictly separate
the public C API, the stable C API (Py_LIMITED_API), and the internal
C API (Py_BUILD_CORE).

Move internal headers to Include/internal/ :
https://bugs.python.org/issue35081

Move !Py_LIMITED_API to Include/pycapi/:
https://bugs.python.org/issue35134

I tried to ensure that Py_BUILD_CORE is defined when including
pycore_xxx.h headers from Include/internal/, but the compilation of
the _json module fails. Modules/_json.c contains:

/* Core extension modules are built-in on some platforms (e.g. Windows). */
#ifdef Py_BUILD_CORE
#define Py_BUILD_CORE_BUILTIN
#undef Py_BUILD_CORE
#endif

I don't understand the difference between Py_BUILD_CORE and
Py_BUILD_CORE_BUILTIN defines. Do we need to have two different
defines? Can't we compile _json with Py_BUILD_CORE?

_json.c uses pycore_accu.h:

/*
 * A two-level accumulator of unicode objects that avoids both the overhead
 * of keeping a huge number of small separate objects, and the quadratic
 * behaviour of using a naive repeated concatenation scheme.
 */

Is it a problem of the visibility/scope of symbols in the python DLL on Windows?

Victor


More information about the Python-Dev mailing list