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
64883c7d
Commit
64883c7d
authored
Mar 08, 2010
by
bryancole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a test to check that the object refcount is not incremented in C-
methods. Also exercises the nogil label.
parent
3594f918
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
tests/run/refcount_in_meth.pyx
tests/run/refcount_in_meth.pyx
+67
-0
No files found.
tests/run/refcount_in_meth.pyx
0 → 100644
View file @
64883c7d
#!/usr/bin/env python
__doc__
=
u"""
>>> t = RefCountInMeth()
>>> t.chk_meth()
True
>>> t.chk_nogil()
True
>>> t.chk_meth_if()
True
>>> t.chk_nogil_if()
True
"""
import
sys
cdef
class
RefCountInMeth
(
object
):
cdef
double
value
def
__cinit__
(
self
):
self
.
value
=
1.5
cdef
double
c_get_value
(
self
)
nogil
:
return
self
.
value
cdef
double
c_get_value_if
(
self
)
nogil
:
cdef
double
v
if
9
>
4
:
v
=
2.3
return
self
.
value
cdef
int
c_meth
(
self
):
cdef
int
v
v
=
sys
.
getrefcount
(
self
)
return
v
cdef
int
c_meth_if
(
self
):
cdef
int
v
if
5
>
6
:
v
=
7
v
=
sys
.
getrefcount
(
self
)
return
v
def
chk_meth
(
self
):
cdef
int
a
,
b
a
=
sys
.
getrefcount
(
self
)
b
=
self
.
c_meth
()
return
a
==
b
def
chk_meth_if
(
self
):
cdef
int
a
,
b
a
=
sys
.
getrefcount
(
self
)
b
=
self
.
c_meth_if
()
return
a
==
b
def
chk_nogil
(
self
):
cdef
double
v
v
=
self
.
c_get_value
()
return
v
==
self
.
value
def
chk_nogil_if
(
self
):
cdef
double
v
v
=
self
.
c_get_value_if
()
return
v
==
self
.
value
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