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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
643e267e
Commit
643e267e
authored
May 16, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove nogil extension test blocking cython test suite
parent
621117ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
115 deletions
+0
-115
test.py
test.py
+0
-6
test.pyx
test.pyx
+0
-109
No files found.
test.py
deleted
100644 → 0
View file @
621117ee
from
distutils.core
import
setup
from
Cython.Build
import
cythonize
setup
(
ext_modules
=
cythonize
(
"test.pyx"
)
)
\ No newline at end of file
test.pyx
deleted
100644 → 0
View file @
621117ee
#cython: language_level = 3
from
libc.stdio
cimport
printf
"""
GOAL: implement nogil option in cdef class (extension types)
and native memory manager (refcount based) that does not
depend on cpython's memory manager and that does not require GIL.
HINT: look at C++ standard library (that works very nicely with Cython)
Cython documentation if here: http://docs.cython.org/en/latest/
Basic usage: http://docs.cython.org/en/latest/src/quickstart/build.html
Tutorial: http://docs.cython.org/en/latest/src/tutorial/cython_tutorial.html
Language: http://docs.cython.org/en/latest/src/userguide/language_basics.html
Extension types: http://docs.cython.org/en/latest/src/userguide/extension_types.html
Extension Types are the "pure cython" classes that I want to be able to
use without depending on cpython GIL (and in essence runtime, memory manager, etc.)
Cython memory allocation: http://docs.cython.org/en/latest/src/tutorial/memory_allocation.html
Parallelism: http://docs.cython.org/en/latest/src/userguide/parallelism.html
Explains how nogil is posisble in cython for anything that
only relies on C libraries that are multi-threaded
"""
# cdef class SomeMemory:
cdef
cypclass
SomeMemory
:
"""
This is a cdef class which is also called
a extensino type. It is a kind of C struct
that also acts as a python object.
We would like to be able to define "nogil"
extension types:
cdef class SomeMemory nogil:
where all methods are "nogil" and memory
allocation does not depend on python runtime
"""
double
a
;
double
b
;
void
__init__
(
double
a
,
double
b
):
this
.
a
=
a
this
.
b
=
b
void
foo
()
nogil
:
"""
It is possible to define native C/Cython methods
that release the GIL (cool...)
"""
this
.
a
=
this
.
b
void
foo1
(
int
a
)
nogil
:
"""
It is possible to define native C/Cython methods
that release the GIL (cool...)
"""
this
.
a
=
a
void
foo3
()
nogil
:
"""
It is possible to define native C/Cython methods
that release the GIL (cool...)
"""
pass
# Not allowed to define pure Python function in the extension type with nogil option now
# since we want this extension type is CPython free
# def baz(self):
# """
# It is also possible to define standard python
# methods
# """
# pass
# cdef bar(): # it is currently impossible to release GIL
cdef
int
bar
()
nogil
:
# 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
to first introduce the concept of nogil in cdef class
"""
cdef
SomeMemory
o
=
SomeMemory
(
42.0
,
3.14
)
# for this we need class allocation to handle memory without libpython
o
.
foo
()
# and we need method selection to be independent of libpython
o
.
foo1
(
2
)
o
.
a
=
1.0
return
0
cpdef
baz
():
"""
This method is both callable from python and pure "cython".
It can call both cdef methods and usual python functions
"""
bar
()
# We call here a cpdef function, which calls a def function
# which then allocates cdef class SomeMemory
baz
()
print
(
"done"
)
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