cython hello world

Create cython hello.pyx script:

def say_hello_to(name):
    print("Hello %s!" % name)

Compile into shared object (credit to
# this will create a hello.c file - the C source code to build a python extension
cython hello.pyx

# Compile the object file
gcc -c -fPIC -I/usr/include/python2.6/ hello.c

# Link it into a shared library
gcc -shared hello.o -o

Now you can import module hello in a regular python script:

from hello import say_hello_to
This entry was posted in Programming, Python and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s