GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — bpo-45459: Rename buffer.h to pybuffer.h by vstinner · Pull Request #31201 · python/cpython Conversation
|
| */ | ||
|
|
||
| // Forward declaration | ||
| typedef struct _object PyObject; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's ugly. I had a forward declaration in my first PR. @encukou asked me to remove it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
How is it "ugly"? Could you be more specific?
There are many similar code used in Python header files to fix inter-dependency issues. See for example Include/pystate.h.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize the reason it was there. It's ugly, but it might be a good way to solve the issue.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I elaborated the comment to explain why this "Forward declaration" is needed. Is it better?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why not forward-define Py_buffer in object.h instead? That's a smaller change anyway, and removes the ordering requirement completely, rather than simply forcing it to happen in a certain way.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I see Py_buffer as a C structure which is unrelated to Python objects. It's like a low-level thing "under" PyObject. In practice, it contains a PyObject* pointer and pybuffer.h contains other function definitions which use PyObject*.
I don't think that the order matters much, both orders work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why not forward-define Py_buffer in object.h instead?
It's not possible: the Py_buffer struct has no name on purpose, see @tiran's comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When you're done making the requested changes, leave the comment: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tiran: Do you prefer to have a forward declaration of Py_buffer in object.h, or a forward declaration of PyObject in pybuffer.h? Well, I wrote my opinion on the order in a comment above, but I don't really care. Or if you prefer, I can put all of these definitions in a new single header file and make sure that it's one of the first included header. As I said, there are other header files using such forward declarations to break cycles of dependencies between two header files. In C, it's ok to use |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@encukou asked me to make Py_buffer an anon struct typedef. C does not support forward declaration of anon struct. You either have to give the Py_buffer struct a name again or keep your approach. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Well, this PR works and doesn't require to give a name to the anonymous Py_buffer struct :-) @tiran: GitHub still tells me that there is "1 change requested" from your side. Can you either remove your -1 vote or vote +1 (approve)? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@vstinner: Please replace |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I merged my fix. Thanks for reviews. It's unclear to me why the Py_buffer struct has no name, but well, I'm fine with no giving it a name :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.