Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
77c9f1e1
Commit
77c9f1e1
authored
Feb 05, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nogil tests with ccdef
parent
cbd925a3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
nogil_test/nogil_extension.pyx
nogil_test/nogil_extension.pyx
+8
-8
No files found.
nogil_test/nogil_extension.pyx
View file @
77c9f1e1
...
...
@@ -32,7 +32,7 @@ from libc.stdio cimport printf
# cdef class SomeMemory:
c
def
class
SomeMemory
nogil
:
c
cdef
class
SomeMemory
:
"""
This is a cdef class which is also called
a extensino type. It is a kind of C struct
...
...
@@ -41,7 +41,7 @@ cdef class SomeMemory nogil:
We would like to be able to define "nogil"
extension types:
c
def class SomeMemory nogil
:
c
cdef class SomeMemory
:
where all methods are "nogil" and memory
allocation does not depend on python runtime
...
...
@@ -49,22 +49,22 @@ cdef class SomeMemory nogil:
cdef
int
a
;
cdef
double
b
;
c
def
void
cinit
(
self
,
a
,
b
)
nogil
:
c
cdef
void
cinit
(
self
,
a
,
b
)
:
# self.a = a
# self.b = b
pass
c
def
void
cdealloc
(
self
)
nogil
:
c
cdef
void
cdealloc
(
self
)
:
pass
c
def
void
foo1
(
self
)
nogil
:
c
cdef
void
foo1
(
self
)
:
"""
It is possible to define native C/Cython methods
that release the GIL (cool...)
"""
self
.
a
+=
3
c
def
void
foo2
(
self
)
nogil
:
c
cdef
void
foo2
(
self
)
:
"""
It is possible to define native C/Cython methods
that release the GIL (cool...)
...
...
@@ -82,7 +82,7 @@ cdef class SomeMemory nogil:
# cdef bar(): # it is currently impossible to release GIL
c
def
double
bar1
()
nogil
:
# yet this is what we would like to
c
cdef
double
bar1
()
:
# yet this is what 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
...
...
@@ -94,7 +94,7 @@ cdef double bar1() nogil: # yet this is what we would like to
return
o1
.
a
c
def
double
bar2
()
nogil
:
# yet this is what we would like to
c
cdef
double
bar2
()
:
# yet this is what we would like to
cdef
SomeMemory
o2
=
SomeMemory
(
2
,
2.0
)
o2
.
foo2
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment