0

I want to add method for one class implemented by C

from lru import LRU
class A(LRU):
    def foo(self):
        print("a")

lru is a lib from https://github.com/amitdev/lru-dict

error:“type ‘type’ is not an acceptable base type”

Cherrymelon
  • 412
  • 2
  • 7
  • 17
  • if you compile LRU by yourself, then you could use: `ctypes.cdll.LoadLibrary()` to load the library. Not sure if this works, but worth the try! – bert Mar 27 '23 at 11:26
  • @bert I just want to make thing simple by using packed python wheel,Could you explain why the class implement by C can't be inherited? – Cherrymelon Mar 28 '23 at 05:49

1 Answers1

0

Writing Python's inheritable C/C++ types is contained in this PEP 253. Also, you have this guide that explains how to write inheritable types in C/C++.

bert
  • 372
  • 4
  • 13
  • 2
    This is basically a link-only answer, which is frowned upon on Stack Overflow. It would be better to explain why this type isn't inheritable, and refer to the PEP or guide if needed. – AKX Mar 28 '23 at 07:11