Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7914005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:58:40+00:00 2026-06-03T13:58:40+00:00

As there are multitude of ways to write binary modules for python, i was

  • 0

As there are multitude of ways to write binary modules for python, i was hopping those of you with experience could advice on the best approach if i wish to improve the performance of some segments of the code as much as possible.

As i understand, one can either write an extension using the python/numpy C-api, or wrap some already written pure C/C++/Fortran function to be called from the python code.

Naturally, tools like Cython are the easiest way to go, but i assume that writing the code by hand gives better control and provide better performance.

The question, and it may be to general, is which approach to use. Write a C or C++ extension? wrap external C/C++ functions or use callback to python functions?

I write this question after reading chapter 10 in Langtangen’s “Python scripting for computational science” where there is a comparison of several methods to interface between python and C.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:58:41+00:00Added an answer on June 3, 2026 at 1:58 pm

    I would say it depends on your skills/experience and your project.
    If this is very ponctual and you are profficient in C/C++ and you have already written python wrapper, then write your own extension and interface it.

    If you are going to work with Numpy on other project, then go for the Numpy C-API, it’s extensive and rather well documented but it is also quite a lot of documentation to process.
    At least I had a lot of difficulty processing it, but then again I suck at C.

    If you’re not really sure go Cython, far less time consuming and the performance are in most cases very good. (my choice)
    From my point of view you need to be a good C coder to do better than Cython with the 2 previous implementation, and it will be much more complexe and time consuming.
    So are you a great C coder ?

    Also it might be worth your while to look into pycuda or some other GPGPU stuff if you’re looking for performance, depending on your hardware of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many algorithms for finding optimal binary search trees given a set of
I know that there are a multitude of text editors for the iPhone. I'm
There are a multitude of questions here relating to locking movie playback into landscape
I know there are a multitude of questions regarding putting a navigation controller into
We all know that logging is very important, and that there are a multitude
Is there a listing or simple copy/paste anywhere for the multitude of symbols commonly
There are a multitude of key-value stores available. Currently you need to choose one
What's the best way to write to the middle of a text file in
There is this SQL Statement SELECT t1.Name ,Count(t2.SubID) Totals -- I don't know how
There are numerous places on the Internet, suggesting that it is easily achieved by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.