Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from ctypes to cffi for calling the c code #99

viblo opened this issue May 19, 2016 · 1 comment

Switch from ctypes to cffi for calling the c code #99

viblo opened this issue May 19, 2016 · 1 comment


Copy link

viblo commented May 19, 2016

This issue tracks (and is open for any comments) a potential "upgrade" from ctypes to CFFI. CFFI have a number of advantages but also a downsides.

Advantages (compared to ctypes):

  1. Its an active project. The developers and users are active, there are new releases being made and its possible to ask and get answers within a day on the CFFI mailing list.
  2. Its said to be the way forward for pypy, with promise of better performance compares to ctypes.
  3. A little easier than ctypes to wrap things since you can just copy-paste the c headers.

Disadvatages (compared to ctypes):

  1. ctypes is part of the CPython standard library, CFFI is not. That means that it will be more difficult to install Pymunk if it uses CFFI, since a copy-paste install is no longer possible in an easy way.

For me I see the 1st advantage as the main point. I have had great difficulties with strange segfaults with 64bit pythons on windows, and also sometimes on 32bit python, and support for 64bit python on both windows and linux is something I really want. Hopefully those problems will be easier to handle with CFFI since it has an active community.

Then comes the 3rd advantage, that its a bit easier to wrap the c code. For ctypes I have a automatic wrapping script that does most of the low level wrapping, but its not supported, very difficult to set up (I only managed inside a VM with linux) and quite annoying. CFFI would be a clear improvement.

For the disadvantage of ctypes I think it will be acceptable, even if not ideal. Many python packages have to be installed in some way (like pygame), and nowadays with pip its very easy to do. So I hope that it will be ok.

Current work on CFFI can be tracked in the cffi branch

Feel free to post any thoughts or comments on this issue!

Copy link
Owner Author

viblo commented Jul 17, 2016

cffi now used in pymunk 5.0

@viblo viblo closed this as completed Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant