Message390411
> 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. |
|
Date |
User |
Action |
Args |
2021-04-07 10:33:31 | vstinner | set | recipients:
+ vstinner, tim.peters, rhettinger, mark.dickinson, Mark.Shannon, pablogsal, shihai1991 |
2021-04-07 10:33:31 | vstinner | set | messageid: <1617791611.36.0.361293751654.issue43753@roundup.psfhosted.org> |
2021-04-07 10:33:31 | vstinner | link | issue43753 messages |
2021-04-07 10:33:28 | vstinner | create | |
|