Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Daniel Haude Newsgroups: comp.lang.python Subject: Writing SOME class methods in C Date: 18 Nov 2015 07:50:30 GMT Lines: 25 Message-ID: X-Trace: individual.net 81EWmZPW96RtRm9fPOK00g2wVY4Akx7lqzGCEvP3bE3Wn9V5tb Cancel-Lock: sha1:ScjgM2WHRAgCP8HiddOa7sd9Zbg= User-Agent: slrn/1.0.2 (Linux) Xref: csiph.com comp.lang.python:98948 Hello, I'm trying to implement some (but not all) methods of a Python class in C. What I've found on the Net is: - how to implement entire modules in C so that I can import that module and use the C functions (successfully done it, too). - how to implement entire classes in C But I can't find any examples of modules which consist of a mixture of C and Python, nor modules that define classes of which some members are implemented in C, others in Python. Of course, once I have the "mixture" bit figured out I could just define wrapper class methods that call C functions (functions impleneted in C, that is). But I would find it rather elegant if the C function could access the class members directly. The fact that the C extension functions have a mandatory "PyObject *self" parameter tells me that this must be somehow possible, but I don't know how. I'm sure that many of the plethora of Python extension modules out there must use the technique that I'm looking for, but I don't even know where to start looking. Pointers are welcome. Thanks, robert