Cython issue with Operator "execute" function

Blargh. Google didn’t turn up anything with regard to this error. I’m compiling a .pyx file with a bpy.types.Operator class in it. It compiles fine on Windows, but I get an error when I start Blender and it tries to register my addon:


File "operators.pyx", line 640, in operators.register
TypeError: expected Operator, VIEW3D_OT_AddObjects class "execute" attribute to be a function, not a instancemethod

I don’t understand why it’s making this distinction. The addon works flawlessly as pure Python - the Operator’s execute() function runs just fine. In truth, all I’ve even done yet is change the file extension from .py to .pyx, compile it, and try to load the compiled module.

I’ve done this very thing quite a few times, and I’ve never seen this error before. Help?

You do not need to compile Python. Why would you want to do that? I am no programmer, but the way I understand it is not meant to be compiled in this situation. What are you trying to achieve?

http://cython.readthedocs.io/en/latest/src/tutorial/pure.html

Well, I googled that much before posting. This does make sense in case a separate application is being developed using Python, but we are talking about an addon that is using an API of another application. If it’s converted to C and then compiled and then runs as byte code, how does it import Blender’s python classes, objects and functions and interpret them? I tend to think there would be problems there. But again, I am not a programmer. I will be very interested to see a response of someone more experienced.

Have you tested this compiling process with something really simple just to see if it works?

Editing my post. I’m not sure now whether I’ve specifically compiled modules with classes inheriting from Blender’s bpy.types.

Cython…, I’ve never gotten over the compiler issue so I can’t do much but have you tried cffi? You can call the C code directly with it

It will depend on what Cython generates exactly.

The operator is a collection of C functions wrapped inside a PyObject which is the official way to wrap C code for Python with the C API and what Cython has to use.

If the PyObject is in some way incompatible with Blender and it may be in way you are not aware of , it wont work.

Also how you compile it, if its compiled like Cython does into a pyd module, this is basically a dll but a dll will not have access to the Blender memory thus it wont be able to communicate with Blender code, thus your operator wont work.

Remember python in Blender is embedded so for your code to really work if it generates C code that code will have to built Together with Blender to work.

You may think that you trying to do is simple, but it is not simple at all there are like a gazillion things that can go wrong here. I am suprised that it even gives you an actual error and does not crash Blender without an error.