Commit 36ab0511 authored by Boxiang Sun's avatar Boxiang Sun


parent 1b0999f9
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
ext_modules = [
ext_modules = cythonize("test.pyx")
\ No newline at end of file
ext_modules = cythonize(ext_modules)
#cython: language_level = 3
from cython.parallel import parallel
from libc.stdio cimport printf
GOAL: implement nogil option in cdef class (extension types)
......@@ -53,8 +54,8 @@ cdef class SomeMemory nogil:
It is possible to define native C/Cython methods
that release the GIL (cool...)
# self.a = self.b
while 1:
self.a += 1
# Not allowed to define pure Python function in the extension type with nogil option now
# since we want this extension type is CPython free
......@@ -76,8 +77,9 @@ cdef double bar() nogil: # yet this is what we would like to
# cdef SomeMemory o = SomeMemory(42.0, 3.14) # for this we need class allocation to handle memory without libpython
cdef SomeMemory o1 = SomeMemory(1, 1.0)
cdef SomeMemory o2 = SomeMemory(2, 2.0)
with nogil, parallel():
# # and we need method selection to be independent of libpython
# o.foo1(2)
# o.a = 2.732
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment