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
Boxiang Sun
cython
Commits
36ab0511
Commit
36ab0511
authored
Dec 17, 2018
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test
parent
1b0999f9
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4063 additions
and
7 deletions
+4063
-7
test.c
test.c
+3447
-1
test.html
test.html
+598
-0
test.py
test.py
+12
-2
test.pyx
test.pyx
+6
-4
No files found.
test.c
View file @
36ab0511
This source diff could not be displayed because it is too large. You can
view the blob
instead.
test.html
0 → 100644
View file @
36ab0511
This diff is collapsed.
Click to expand it.
test.py
View file @
36ab0511
from
distutils.core
import
setup
from
distutils.extension
import
Extension
from
Cython.Build
import
cythonize
ext_modules
=
[
Extension
(
'test'
,
[
'test.pyx'
],
extra_compile_args
=
[
'-fopenmp'
],
extra_link_args
=
[
'-fopenmp'
],
)
]
setup
(
ext_modules
=
cythonize
(
"test.pyx"
)
)
\ No newline at end of file
ext_modules
=
cythonize
(
ext_modules
)
)
test.pyx
View file @
36ab0511
#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...)
"""
pass
# 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
)
o1
.
foo
()
o2
.
foo
()
with
nogil
,
parallel
():
o1
.
foo
()
o2
.
foo
()
# o.foo() # and we need method selection to be independent of libpython
# o.foo1(2)
# o.a = 2.732
...
...
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