Closed malemburg closed 1 year ago
Just to clarify: I'm willing to help with all this, if people would like to have me in such a workgroup.
The next steps seem to be answering these, respectively:
sys
). When that's working, we can see if a C function is needed -- most likely this won't be needed in a tight loop so a PySys_SetObject
might suffice.Do you have some concrete (partial) answers already? Or do we need to do research and, say, establish some criteria for what to fix/include?
I could go through the API and answer your questions, but isn't the point of a workgroup to do such things in a more collaborative and interactive way, after we have established how we want to tackle such problems (e.g. splitting up the work in chunks, one ticket per API, group of APIs, design pattern, etc) ?
Some example for the above:
This is what attracted me to Python back in 1994, when I was mostly a C programmer, and I would like Python to regain this elegance on the C side of things.
I think this issue is too broad to be useful for our current effort, which is to identify (1) specific problems with the c api that need to be resolved in a new one and (2) specific strengths that should be preserved.
You mention several items in the first category. Could you create an issue for each of them? Try to avoid discussing solutions at this stage.
@malemburg: I think your list does not lend itself to a uniform "API design committee" approach.
@steve-s: I'm not sure I buy the glue language dichotomy, especially the no-GIL example. IIUC, no-GIL can be essential for people who use Python as a glue language that wraps a large C library that is fundamentally multi-threaded. Callbacks from C to Python currently have to deal with the GIL in a very awkward way. So the existence of parallel algorithms written in C actually make no-GIL relevant.
@steve-s: I'm not sure I buy the glue language dichotomy, especially the no-GIL example. IIUC, no-GIL can be essential for people who use Python as a glue language that wraps a large C library that is fundamentally multi-threaded. Callbacks from C to Python currently have to deal with the GIL in a very awkward way. So the existence of parallel algorithms written in C actually make no-GIL relevant.
Maybe the no-GIL wasn't a good example, because it can be useful for "glue language" use-case in the way you mention, which makes it confusing. Another example: faster CPython. It's better for highly optimized interpreter if the internal details are hidden and can be flexible, while if you think of Python as a "glue language", then speeding up the interpreter is not much useful (all the heavy computations happen in native code) and hiding implementation details is bad because you want a raw access for maximal performance of the native part.
Of course, it's not one or the other, but I also believe that there's no free lunch. One cannot have fast C API with direct access to internal data-structures and at the same time modern advanced VM. No-GIL could have used tracing GC instead of the biased reference counting, if reference counting was not exposed, for example.
@gvanrossum: I think your list does not lend itself to a uniform "API design committee" approach.
From your and Irit's reply I read that I probably wasn't clear enough in my original description. I'm going to try again:
I was not at the PyCon US meeting where the capi workgroup was apparently discussed, so perhaps I'm missing some context, but from looking through this repo, I could not find any clue as to how this workgroup will operate, who its members are and what the design goals should be.
I think it's a good idea to have such a workgroup, but for it to be useful we will need some clear mission or perhaps vision of what the workgroup should strive for. Simply collecting lots and lots of often very specific requests is not going to help with this, since it's not clear how those requests should be handled, whether they fit the common goal the workgroup has and how and where the workgroup will discuss and perhaps vote on the various requests.
The tickets in this "problems" repo clearly show that there are lots of different views on where the C API should be heading, from the "make it as complete and useful as possible for C extension writers" all the way to "we should only have a high level minimal C API".
While it's good to collect ideas, I believe it's necessary to give people an idea of the general plan first, before they spend many hours digging through the existing APIs and suggesting to turn private into public APIs or proposing new approaches to the design and investing a lot of time into proposals (everything from "let's do a Python C API 2.0 from scratch", via "let's replace pointers with handles" to "how about adding a level of indirection similar to the Windows COM design for better separation of implementation vs. API").
To answer @iritkatriel: Yes, I can open new tickets for the examples I've given (and probably will), but that was not really what I was after. IMO, we need to have more structure first and a clearer vision of what we're after, before making more specific suggestions. E.g. if the vision turns out to be "we should only have a high level minimal C API", those new tickets would likely mostly be pointless.
Hopefully, I've made my motivation a little clearer this time π
Aside: The point about the config API was triggered by my implementation of eGenix PyRun, where I replace a lot of the Python startup time C code with an implementation written in Python (similar to the importlib effort). Since the code still needs to change those config variables after the interpreter has started running, I'm currently faced with a problem and will probably have to abandon the approach. OTOH, this may actually be something we'd want to have in CPython going forward to untangle the startup procedures we currently have in C. I'll add this context to a separate ticket to discuss.
The point of this repo at the moment is not to discuss the future of the C API but rather to get to a shared understanding of what its current state is. See draft for the document describing this shared understanding at: https://github.com/capi-workgroup/problems/blob/main/capi_problems.rst
@malemburg
I was not at the PyCon US meeting where the capi workgroup was apparently discussed, so perhaps I'm missing some context, but from looking through this repo, I could not find any clue as to how this workgroup will operate, who its members are and what the design goals should be.
It was the language summit. See https://pyfound.blogspot.com/2023/05/the-python-language-summit-2023-three.html.
There is currently no membership, we plan to have a meeting in Brno with everyone who's at the sprint to discuss further steps, who's going to do what, etc. I hope you are planning to attend, as it is not that far for you?
Looking back at the subject of this issue ("Clean up the Python C API for consistency, completeness and usefulness") I think this issue is too general to be of use for the C API working group. I'll close it. We know that we want all those things already.
The point of this repo at the moment is not to discuss the future of the C API but rather to get to a shared understanding of what its current state is. See draft for the document describing this shared understanding at: https://github.com/capi-workgroup/problems/blob/main/capi_problems.rst
Thanks for the pointer, @iritkatriel. I've read the document and now have a better idea of what you're after.
I still don't fully understand what you consider a "problem", since that's essentially framed by the goals we're after, but I guess you want everyone to simply put forward whatever they consider a "problem" based on their own goals, which is fine.
It was the language summit. See https://pyfound.blogspot.com/2023/05/the-python-language-summit-2023-three.html.
There is currently no membership, we plan to have a meeting in Brno with everyone who's at the sprint to discuss further steps, who's going to do what, etc. I hope you are planning to attend, as it is not that far for you?
Thanks for the link to the summit page. @gvanrossum. I read that as well and found the reasoning there to be very similar to discussions I see on Discourse or at conferences: there's no clear direction and that's the main obstacle we currently have in determining, where things should or should not be heading.
I won't be attending the sprint at Brno, but perhaps there's an option to listen in on the conversations you are having on Discord, if I can make those meetings (virtually).
Looking back at the subject of this issue ("Clean up the Python C API for consistency, completeness and usefulness") I think this issue is too general to be of use for the C API working group. I'll close it. We know that we want all those things already.
I'll take that as documentation of a first goal we have in setting the perspective for a clearer C API vision π .
I'm sorry, I doubt that there will be an option to participate in the sprint discussions online; the logistics of that are too complicated, and we may have many smaller "hallway" discussions that wouldn't be captured anyways. But we will be sure to produce a document (or documents) with a conclusion and next steps.
You sound critical of our process. We're doing the best we can, first gathering input (this tracker), then summarizing it (Irit's doc), then having a focused discussion about direction and next steps (Brno). I think that's the best we can do.
You sound critical of our process. We're doing the best we can, first gathering input (this tracker), then summarizing it (Irit's doc), then having a focused discussion about direction and next steps (Brno). I think that's the best we can do.
I'm not really critical of the process you have chosen. I am very used to working in the context of PSF, EPS and other workgroups, where these things are always documented in the early stages of their creation, hence me wondering what the goals are and how to participate π.
What I am missing is better communication of the effort, an open invitation to Python extension writers to participate and a short introduction of the goals and how the group envisions coming up with a strategy. Perhaps I should open a ticket for this and follow up there.
What I am missing is better communication of the effort, an open invitation to Python extension writers to participate and a short introduction of the goals and how the group envisions coming up with a strategy. Perhaps I should open a ticket for this and follow up there.
Maybe you can send a PR with an update to the README for this repo?
We deliberately made it by invitation initially and not announced it widely so we can make some progress with little noise. The next stage should be to solicit wider feedback.
Maybe you can send a PR with an update to the README for this repo?
I'll see what I can come up with π
We deliberately made it by invitation initially and not announced it widely so we can make some progress with little noise. The next stage should be to solicit wider feedback.
Great π
Maybe you can send a PR with an update to the README for this repo?
I'll see what I can come up with π
Done. Please see https://github.com/capi-workgroup/problems/pull/72
There have been long discussions on Discourse about how to go about dealing with C API changes, deprecations, private vs. public and ABI stability promises.
I think it's time to sit down and have a workgroup discuss and design the way forward. My hope is that this repo can turn into that workgroup, but we'd need some form of governance, regular meetings and deliverables for this to work out.
In any case, looking at the C API as it stands now, I find that (or perhaps I'm looking in the wrong places):
I'm not a fan of redesigns, but instead would like to see the C API evolve over time and if this takes longer, that's perfectly fine.
There aren't all that many places which really expose internals in a way which hinders future development, e.g. APIs targeting the VM. Those can be treated with different strategies, while clearly stating our goals and promises we make.
For most other APIs, it's important to make the C API enjoyable for C programmers (again), providing a rich API with good tooling to tap into Python objects in an efficient way. This is what attracted me to Python back in 1994, when I was mostly a C programmer, and I would like Python to regain this elegance on the C side of things.