top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Writing Extensions for Python 3 in C

0 votes
426 views

I have searched for lots of tutorials and documentation on the web but, didnt find a decent one to develop extensions for Python 3 using a custom compiler (mingw32, nvcc). Please help me. PS: Dont point me to Python Documentation. It is not good for beginners. It doesnt elaborate about calls and implementation.

posted Jun 19, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes
 
Best answer

There is even a tutorial here:

http://docs.python.org/3/extending/index.html

Have you tried that yet? Doing it with a different compiler is something I would save for a second step. Maybe if you described your problems with a bit more detail would help.

answer Jun 19, 2013 by anonymous
0 votes

You need to tell what youve read, what youve tried, where stuck. Yes the extending and embedding stuff http://docs.python.org/2/extending/ and
http://docs.python.org/2/c-api/index.html is more difficult than much other than other python docs.

That is intrinsic to the problem -- you are not in the python world but the C world and C is a much harder and headachey-er than python. And building the python infrastructure on top of that is still harder.

If you have to use it, you really need to get the data-structure invariants right: eg http://docs.python.org/2/c-api/intro.html#objects-types-and-reference-counts.

However as Terry suggests, using something like Cython to avoid this should always be first explored. Heres a list

  1. 'Classic' extending/embedding
  2. SCXX
  3. PyCXX
  4. Boost
  5. Ctypes
  6. Swig
  7. Sip
  8. cython

Explore in reverse order!

answer Jun 19, 2013 by anonymous
Similar Questions
+1 vote

I understand there have been changes to the way that extensions are supposed to be built for windows. Is there any user documentation regarding these changes?

Last time I looked the appropriate Visual Studio hadn't been release so I guess I will need to use my MSDN skills (or incantations) to first get that installed.

+1 vote

For example:

a=[-15,-30,-10,1,3,5]

I want to find a negative and a positive minimum.

example: negative
print(min(a)) = -30

positive
print(min(a)) = 1
...