Create a Python type from C that implements a __dict__?

前端 未结 4 2258
日久生厌
日久生厌 2021-02-15 16:22
  • How is a type created to have a __dict__ as per a \"normal\" class would have were it defined in Python?
  • Are there any examples of non-dynamic types
4条回答
  •  别跟我提以往
    2021-02-15 16:57

    I haven't done this, I'm embarrasingly bad on using the C-API, but according to the docs it should be enough with using PyObject_GenericGetAttr and PyObject_GenericSetAttr for the getattro and setattro methods. You also need to have a PyObject attribute called __dict__ of course.

    Have you tried that?

提交回复
热议问题