This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Decorater
Recipients Decorater, docs@python
Date 2017-05-17.17:56:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495043805.38.0.403862403913.issue30390@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-05-17 17:56:45Decoratersetrecipients: + Decorater, docs@python
2017-05-17 17:56:45Decoratersetmessageid: <1495043805.38.0.403862403913.issue30390@psf.upfronthosting.co.za>
2017-05-17 17:56:45Decoraterlinkissue30390 messages
2017-05-17 17:56:44Decoratercreate