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
Kirill Smelkov
cython
Commits
c8820cf9
Commit
c8820cf9
authored
Jun 05, 2021
by
da-woods
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed optimizations in defined cppclass
The problem was they were being skipped with SkipDeclarations
parent
b3f8a198
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+7
-0
tests/run/cpp_classes_def.pyx
tests/run/cpp_classes_def.pyx
+4
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
c8820cf9
...
...
@@ -52,6 +52,13 @@ class SkipDeclarations(object):
def
visit_CStructOrUnionDefNode
(
self
,
node
):
return
node
def
visit_CppClassNode
(
self
,
node
):
if
node
.
visibility
==
"extern"
:
return
node
else
:
self
.
visitchildren
(
node
)
return
node
class
NormalizeTree
(
CythonTransform
):
"""
...
...
tests/run/cpp_classes_def.pyx
View file @
c8820cf9
...
...
@@ -9,6 +9,7 @@ from libcpp cimport bool
from
libcpp.memory
cimport
unique_ptr
from
libcpp.vector
cimport
vector
from
cython.operator
cimport
dereference
as
deref
import
cython
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
cdef
cppclass
Shape
:
...
...
@@ -23,6 +24,9 @@ cdef cppclass RegularPolygon(Shape):
float
area
()
const
:
cdef
double
theta
=
pi
/
this
.
n
return
this
.
radius
*
this
.
radius
*
sin
(
theta
)
*
cos
(
theta
)
*
this
.
n
@
cython
.
test_assert_path_exists
(
'//SwitchCaseNode'
)
# optimized correctly (https://github.com/cython/cython/issues/4212)
int
in_list
(
int
x
):
return
x
in
[
1
,
2
,
3
]
def
test_Poly
(
int
n
,
float
radius
=
1
):
"""
...
...
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