0

There is no code here, yet. I'm trying to get a handle on the design.

I'm looking at implementing a project in Python 3 which needs an extension written in C/C++.

There is an existing python class that does most of what I want, but needs extended behavior of one method.

If this were a pure python solution, I'd just subclass the existing class, and write the new method to overload the parent class's method.

How do I do python subclassing in a C extension?

That would be much cleaner than rewriting the whole class, or worse yet, having to implement the whole project in C or C++.

mikb
  • 195
  • 13
  • 1
    You tagged this question `cython`, but seem to imply that you're writing an CPython extension in C++. Which approach are you taking? – Brian61354270 Apr 10 '20 at 22:27
  • In the Python-c-api [this](https://stackoverflow.com/questions/8066438/how-to-dynamically-create-a-derived-type-in-the-python-c-api) is the realistic solution. Cython can automate this with python-like code, but I think you've applied the tag mistakenly. – DavidW Apr 10 '20 at 22:27
  • @Brian: tbh, I haven't decided the approach yet,which is why I didn't include any code. However, it's probably better for SO relevance if I remove the Cython tag – mikb Apr 11 '20 at 01:16

0 Answers0