Commit 77c9f1e1 authored by gsamain's avatar gsamain

Nogil tests with ccdef

parent cbd925a3
...@@ -32,7 +32,7 @@ from libc.stdio cimport printf ...@@ -32,7 +32,7 @@ from libc.stdio cimport printf
# cdef class SomeMemory: # cdef class SomeMemory:
cdef class SomeMemory nogil: ccdef class SomeMemory:
""" """
This is a cdef class which is also called This is a cdef class which is also called
a extensino type. It is a kind of C struct a extensino type. It is a kind of C struct
...@@ -41,7 +41,7 @@ cdef class SomeMemory nogil: ...@@ -41,7 +41,7 @@ cdef class SomeMemory nogil:
We would like to be able to define "nogil" We would like to be able to define "nogil"
extension types: extension types:
cdef class SomeMemory nogil: ccdef class SomeMemory:
where all methods are "nogil" and memory where all methods are "nogil" and memory
allocation does not depend on python runtime allocation does not depend on python runtime
...@@ -49,22 +49,22 @@ cdef class SomeMemory nogil: ...@@ -49,22 +49,22 @@ cdef class SomeMemory nogil:
cdef int a; cdef int a;
cdef double b; cdef double b;
cdef void cinit(self, a, b) nogil: ccdef void cinit(self, a, b):
# self.a = a # self.a = a
# self.b = b # self.b = b
pass pass
cdef void cdealloc(self) nogil: ccdef void cdealloc(self):
pass pass
cdef void foo1(self) nogil: ccdef void foo1(self):
""" """
It is possible to define native C/Cython methods It is possible to define native C/Cython methods
that release the GIL (cool...) that release the GIL (cool...)
""" """
self.a += 3 self.a += 3
cdef void foo2(self) nogil: ccdef void foo2(self):
""" """
It is possible to define native C/Cython methods It is possible to define native C/Cython methods
that release the GIL (cool...) that release the GIL (cool...)
...@@ -82,7 +82,7 @@ cdef class SomeMemory nogil: ...@@ -82,7 +82,7 @@ cdef class SomeMemory nogil:
# cdef bar(): # it is currently impossible to release GIL # cdef bar(): # it is currently impossible to release GIL
cdef double bar1() nogil: # yet this is what we would like to ccdef double bar1(): # yet this is what we would like to
""" """
This is a pure "cython method" which we would like to This is a pure "cython method" which we would like to
be able to declare with nogil option but this requires be able to declare with nogil option but this requires
...@@ -94,7 +94,7 @@ cdef double bar1() nogil: # yet this is what we would like to ...@@ -94,7 +94,7 @@ cdef double bar1() nogil: # yet this is what we would like to
return o1.a return o1.a
cdef double bar2() nogil: # yet this is what we would like to ccdef double bar2(): # yet this is what we would like to
cdef SomeMemory o2 = SomeMemory(2, 2.0) cdef SomeMemory o2 = SomeMemory(2, 2.0)
o2.foo2() o2.foo2()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment