Search code examples
pythoncapipython-c-api

Explanation of PyAPI_DATA() macro?


I've searched all over the web and can't seem to find documentation or even a simple explanation of what PyAPI_DATA() does (even though it is used in the Python header files and cited on python.org). Could anyone care to explain what this is or point me to documentation I am overlooking?

Thanks.


Solution

  • It's used to mark public API variables (as Python's core is usually a dynamic library), e.g. on Windows, it's expanded to extern __declspec(dllexport) RTYPE when core is compiled and to extern __declspec(dllimport) RTYPE when e.g. modules are compiled. It's defined in Include/pyport.h.