New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to make classes in the C API. #74575
Comments
On the C API, it tells how to make modules, functions, variables, and other things, but what about classes? Like for example if you wanted to make a class with all of the methods having to use direct C Code which would then be converted to PyObject *'s for returning the information the C Code would normally return. Not only that but also being able to create class instance variables using the C API as well. Like for example here is an example class (As it would be if it was written in python): class Example:
def __init__(self):
self.data = None # None being a place holder for now.
def somefunction(self):
# C Code here.
self.data = ret # return value for the C Code.
return self.data Yes, there are better ways than writing the return data to the instance variable and returning it. That is just an example, I have classes that uses them for other things that does not return anything making the instance variables be the only way to get the data. But yeah long story short I think creating classes with the C API should be documented if not already, or at least an example of doing one to be added as an guide for others wondering how to use the C API to make their own (non exception) classes. |
Hmm seems that when looking at the exports in python36.dll that the following functions seem to not be documented as far as I seen: PyClassMethodDescr_Type There might be more functions dealing with classes that are not documented. However looking through the whole exports would take to long as there are so many. |
This is documented. See https://docs.python.org/3/extending/newtypes.html. |
Still it does look the functions lited in the second comment are undocumented. https://docs.python.org/3/search.html?q=PyClassMethodDescr_Type However on the last function I did find 1 thing However it was not what I was looking for. What I actually was looking for was the args for the 3 functions and description on what it does and all that similar to how this function is documented:
This is actually the reason why the issue was opened as the functions was not documented like this. |
The title of this issue is "Document how to make classes in the C API." This already is documented. For documenting the PyClassMethod* names open a new issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: