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
Xavier Thompson
cython
Commits
a47a6b9e
Commit
a47a6b9e
authored
May 22, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow casts from CyObject to PyObject
parent
5aac7a65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-0
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+19
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
a47a6b9e
...
...
@@ -3960,6 +3960,7 @@ class CypClassType(CppClassType):
# _mro [CppClassType] or None The Method Resolution Order of this cypclass according to Python
is_cyp_class
=
1
to_py_function
=
"__Pyx_PyObject_FromCyObject"
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
,
nogil
=
0
,
lock_mode
=
None
,
activable
=
False
):
CppClassType
.
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
,
template_type
,
nogil
)
...
...
Cython/Utility/CyObjects.cpp
View file @
a47a6b9e
...
...
@@ -159,6 +159,25 @@
return
op
->
CyObject_TRYWLOCK
();
}
/*
* Cast from PyObject to CyObject:
* - borrow an atomic reference
* - return a new Python reference
*
* Note: an optimisation could be to steal a reference but only decrement
* when Python already has a reference, because calls to this function
* are likely (certain even?) to be followed by a Cy_DECREF; stealing the
* reference would mean that Cy_DECREF should not be called after this.
*/
static
inline
PyObject
*
__Pyx_PyObject_FromCyObject
(
CyObject
*
ob
)
{
// artificial atomic increment the first time Python gets a reference
if
(
ob
->
ob_refcnt
==
0
)
ob
->
CyObject_INCREF
();
// return a new Python reference
Py_INCREF
((
PyObject
*
)
ob
);
return
(
PyObject
*
)
ob
;
}
/* Cast argument to CyObject* type. */
#define _CyObject_CAST(op) op
...
...
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