Changes

Jump to navigation Jump to search
no edit summary
====Running Python vs. Cython====
A trial test runon 82 coordinates resulted int the following time stamps: EnclosingCircle in python: 16.069 seconds Enclosing Circle in cython: 9.633 seconds The test files can be found in the following: EnclosingCircle in python: E:\McNair\Projects\Accelerators\EnclosingCircle\EnclosingCircle.py EnclosingCircle in cython: E:\McNair\Projects\Accelerators\EnclosingCircle\EnclosingCircleC_Test.py ====Usage ==== The basic tutorial for cython can be found phttp://docs.cython.org/en/latest/src/tutorial/cython_tutorial.html here]. Essentially, a setup.py file needs to be created with the following format: try: from setuptools import setup from setuptools import Extension except ImportError: from distutils.core import setup from distutils.extension import Extension  from Cython.Build import cythonize setup( ext_modules = cythonize("filename.pyx") ) Then, after changing to the proper directory, execute the following from the command line python setup.py build_ext --inplace This will wrap your python program in C, and produce a filename.pyd file. To use this new python code wrapped in C, simply import the pyd file as if it were a python file: import filename Treat this file as any other module. It will work just as if it were in Python, except it exhibits a faster run time.

Navigation menu