[WIP] _PyTuple_ITEMS() now requires PyTupleObject*#10706
[WIP] _PyTuple_ITEMS() now requires PyTupleObject*#10706vstinner wants to merge 1 commit intopython:masterfrom vstinner:tuple_explicit_cast
Conversation
* Convert _PyTuple_ITEMS() to a static function which requires a PyTupleObject* argument. * Add an assertion to _PyTuple_CAST() to ensure that the argument is a tuple object.
|
Will third-party C code be broken if they don't make these same changes? |
|
I don't like this. This makes the user code cluttered. The public API should use |
|
Sorry, I shouldn't have posted a public PR for this change. I wasn't sure if it was a good idea or not. But sometimes, seeing the diff in GitHub helps me :-)
The C API must not be modified, so third-party code doesn't have to be modified. Note: _PyTuple_ITEMS() function is part of the internal API. I introduced it very recently, so no third-party C extensions don't use and cannot use it :-) Honestly, I'm not sure that this change is worth it. I wasn't sure if the compiler might benefit of it, but when I looked at the machine code, the compiler is always smarter than me and doesn't need my help :-) I abandon this change in favor of the minimum enhancement of _PyTuple_CAST(): PR #10712. |
Right. I mostly wrote this PR to ask myself if there is any benefit of passing directly the right type. I don't see any obvious advantage, so |
Tip: you can create PRs for your own fork. |
Aha, I will try next time. Thanks for the tip :-) |
a PyTupleObject* argument.
a tuple object.