| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| return; | ||
| } | ||
| op->ob_refcnt_split[PY_BIG_ENDIAN] = new_refcnt; | ||
| memcpy(&op->ob_refcnt, &new_refcnt, sizeof(new_refcnt)); |
There was a problem hiding this comment.
Isn't this require the little-endian?
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe move the union here, use memcpy() and only use the bits that you need in the union?
Sorry, something went wrong.
There was a problem hiding this comment.
The problem of the current implementation (without this change) is the usage of anonymous union in PyObject: it is not compatible with (strict) C99. A named union is fine with C89 and C99. It's more about finding the right syntax to get the most efficient code.
Sorry, something went wrong.
|
|
||
| #include <assert.h> // assert() | ||
| #include <wchar.h> // wchar_t | ||
| #include <string.h> // memcpy() |
There was a problem hiding this comment.
It makes me sad to use memcpy() in the limited C API which should attempt to hide as many implementation details as possible. I don't get how the immortal object change interacts with the stable ABI. I would prefer to convert Py_INCREF/Py_DECREF to opaque function calls. It would avoid any C and C++ compatibility issue. At least, it would make the ABI a little bit more "forward compatible".
But that can be done later, since the priority is to unblock the next Python 3.12 beta release.
By the way, the nogil fork has also a completely different implementation which is also ABI incompatible unless these functions are implemented as opaque function calls.
Sorry, something went wrong.
|
I'll be closing since there's better discussions on this in other places |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Currently, the use of an anonymous union causes warnings in C++ extensions. This updates the implementation of PyObject to not rely on anonymous unions and remove these warnings.
Current Issue that goes away after this patch:
#include <Python.h> int main (void) { return 0; } -> gcc -I/path/to/include/python3.13 -std=c99 -pedantic repro.c In file included from repro.c:1: In file included from /Users/eelizondo/dev/cpython_no_union/build_install/include/python3.13/Python.h:44: /Users/eelizondo/dev/cpython_no_union/build_install/include/python3.13/object.h:168:5: warning: anonymous unions are a C11 extension [-Wc11-extensions] union {Note: Currently, this is being fixed through the use of a memcpy but a couple of more options will be tried as well. I will also follow-up with benchmark numbers to verify we are not regressing.