STINNER Victor <vstin...@python.org> added the comment:

> For any sane design of tagged pointers, `x == y` (in C) will work fine.

I wrote a proof-of-concept for using tagged pointners in CPython:
https://github.com/vstinner/cpython/pull/6

"The PR is large because of the first changes which add Py_IS_NONE(), 
Py_IS_TRUE() and Py_IS_FALSE() macros."

For backward compatibility, I added a function to get a concrete Python object 
from a tagged pointer: the True as a tagged pointer becomes (PyObject 
*)&_Py_TrueStruct concrete object. Py_IS_TRUE() has to check for both values: 
tagged pointer or &_Py_TrueStruct (don't look at my exact implementation, it's 
wrong ;-)).

In a perfect world, there would be no backward compatibility and you would 
never have to create Python objects from a tagged pointer.

The other problem is that the stable ABI exposes "Py_True" as "&_Py_TrueStruct" 
and so C extensions built with the stable ABI uses "&_Py_TrueStruct", not the 
tagged pointer.

See also bpo-39511 which discuss solutions for these problems.

----------

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

Reply via email to