Using Structs and Classes with Python Ctypes

preview_player
Показать описание
In this Video, we will explore how to create, pass and return Structs between our C and Python program using the ctypes library.

C File Compilation Code:

Website Link:

Related Links:
Рекомендации по теме
Комментарии
Автор

This video series is a treasure trove. Really appreciate your efforts in making this. While I have only gone through the first couple of videos, I wanted to know if cython is any better than ctype. Why do certain people seem to prefer cython more than ctypes? Are there any demerits to it? Also I notice that you compile the shared library file as a .so file. My recollection of a .so file is it is a linux equivalent of a .dll windows file (dynamically linked library file at runtime). So in your case, is the .so identical to what a .dll is?

cmfanz
Автор

I wish I was smarter so I could understand :(

imveryhungry
Автор

instead of printing the values from the structures in PointArray, how can i store them in the python code, so that i can use the values through out that exact python code?

luisacoelho
Автор

I tried the exact same code specified in the Example #2 where you return a struct via the C file to be used within the python file. Everything is identical. But I get garbage values for x and y instead of 10 and 20.

cmfanz
Автор

Hello, i love your videos! it would be impossible for me to explore ctypes without your tutorials! I have one issue though: Is there a way to save the values of a reutrned pointer? My C-function returns a and i am able to access those values with array[i], however i want to be able to be using this array as a list in python even after i freed the memory..

sebastiansuper
welcome to shbcf.ru