STINNER Victor added the comment:

> Would there be a way to expose these internals rather than hiding them?

Here is the issue is that pyatomic.h cannot be compiled on OpenMP. We had the 
same issue with C++. In fact, it doesn't make sense to compile pyatomic.h 
differently to access an atomic variable from an extension module. We must 
always use exactly the same implementation, otherwise bad things will happen.

A solution for that is to hide the implementation details and only expose high 
level APIs.

For example, pyatomic.h must be completly hidden.

A consequence is that the _PyThreadState_Current variable must be hidden to. 
_PyThreadState_Current is an implementation detail, you must not access it 
directly.

The PyThreadState_GET() macro uses directly the _PyThreadState_Current 
variable. So the solution to expose the "PyThreadState_GET" symbol (not 
necessary as a macro) is to define it as an alias to the PyThreadState_Get() 
*function*.

The advantage of using a function is that we don't expose implementation 
details to third-party extensions, it avoids the risk of ABI incompatibilies.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25150>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to