Cython - Hello World

Hello World

Cython has an unusually involved hello world program because it interfaces with the Python C API and the distutils extension building facility. At least three files are required for a basic project:

  • A setup.py file to invoke the distutils build process that generates the extension module
  • A main python program to load the extension module
  • Cython source file(s)

The following code listings demonstrate the build and launch process.

# hello.pyx def say_hello: print "Hello World!" # launch.py import hello hello.say_hello # setup.py from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = )] setup( name = 'Hello world app', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules )

These commands build and launch the program

$ python setup.py build_ext --inplace $ python launch.py

Read more about this topic:  Cython

Famous quotes containing the word world:

    I have learned more about love, selflessness and human understanding in this great adventure in the world of AIDS than I ever did in the cut-throat, competitive world in which I spent my life.
    Anthony Perkins (1932–1992)

    The monk in hiding himself from the world becomes not less than himself, not less of a person, but more of a person, more truly and perfectly himself: for his personality and individuality are perfected in their true order, the spiritual, interior order, of union with God, the principle of all perfection.
    Thomas Merton (1915–1968)