Add "pycore_pyconfig.h" to split the private configure

This idea is to use pycore_pyconfig.h to avoid the macros not start with Py or _Py go into the user codes. Maybe it can reduce the amount of modifications in the issue #157695.

The private config macros will be moved to this header file. When Py_BUILD_CORE was defined it will be included. Otherwise user cannot include this file.

Someone might be using the macros. Hiding them would be a backwards-incompatible change.

Breaking the relating of the private details is not backwards-incompatible. I think that who are using them should change it unless they have strong reason. In that case it is needed to redesign the macro as a public api.

Things that begin with Py (no underscore) are not private. They’re just owned by Python by virtue of being in the Py namespace.

See the C API compatibility policy for more details.

Also even removing private symbols can be very disruptive and must be done carefully. Historically people were very liberal about using exposed internals and many important C extensions are in maintenance mode.

The macros in this idea often be HAVE_* or SIZEOF_* and so on. The reason to hidden them is that they don’t match the rule that must start with Py, _Py, PY or _PY

Just based on a very quick search, Cython uses HAVE_HYPOT and HAVE_STDARG_PROTOTYPES so you would break existing code with this change.

I’m sure we could cope and work around it if it was really necessary. But that forces people to update to a newer version of Cython. And I’m sure we aren’t the only ones using these macros.

Edit: and a couple of the SIZEOF_ macros too.

2 Likes