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
f65206a8
Commit
f65206a8
authored
Oct 03, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a reference leak for non-simple conditions in boolean and/or expressions
parent
68a5d5d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
CHANGES.rst
CHANGES.rst
+4
-0
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+14
-2
docs/src/userguide/wrapping_CPlusPlus.rst
docs/src/userguide/wrapping_CPlusPlus.rst
+7
-3
tests/build/cpp_cythonize.srctree
tests/build/cpp_cythonize.srctree
+1
-3
No files found.
CHANGES.rst
View file @
f65206a8
...
@@ -8,6 +8,10 @@ Latest
...
@@ -8,6 +8,10 @@ Latest
Features added
Features added
--------------
--------------
* Passing ``language='c++'`` into cythonize() globally enables C++ mode for
all modules that were not passed as Extension objects (i.e. only source
files and file patterns).
* ``Py_hash_t`` is a known type (used in CPython for hash values).
* ``Py_hash_t`` is a known type (used in CPython for hash values).
* ``PySlice_*()`` C-API functions are available from the ``cpython.slice``
* ``PySlice_*()`` C-API functions are available from the ``cpython.slice``
...
...
Cython/Build/Dependencies.py
View file @
f65206a8
...
@@ -586,7 +586,8 @@ def create_dependency_tree(ctx=None, quiet=False):
...
@@ -586,7 +586,8 @@ def create_dependency_tree(ctx=None, quiet=False):
# This may be useful for advanced users?
# This may be useful for advanced users?
def
create_extension_list
(
patterns
,
exclude
=
[],
ctx
=
None
,
aliases
=
None
,
quiet
=
False
,
exclude_failures
=
False
):
def
create_extension_list
(
patterns
,
exclude
=
[],
ctx
=
None
,
aliases
=
None
,
quiet
=
False
,
language
=
None
,
exclude_failures
=
False
):
if
not
isinstance
(
patterns
,
(
list
,
tuple
)):
if
not
isinstance
(
patterns
,
(
list
,
tuple
)):
patterns
=
[
patterns
]
patterns
=
[
patterns
]
explicit_modules
=
set
([
m
.
name
for
m
in
patterns
if
isinstance
(
m
,
Extension
)])
explicit_modules
=
set
([
m
.
name
for
m
in
patterns
if
isinstance
(
m
,
Extension
)])
...
@@ -606,6 +607,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
...
@@ -606,6 +607,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
name
=
'*'
name
=
'*'
base
=
None
base
=
None
exn_type
=
Extension
exn_type
=
Extension
ext_language
=
language
elif
isinstance
(
pattern
,
Extension
):
elif
isinstance
(
pattern
,
Extension
):
for
filepattern
in
pattern
.
sources
:
for
filepattern
in
pattern
.
sources
:
if
os
.
path
.
splitext
(
filepattern
)[
1
]
in
(
'.py'
,
'.pyx'
):
if
os
.
path
.
splitext
(
filepattern
)[
1
]
in
(
'.py'
,
'.pyx'
):
...
@@ -618,6 +620,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
...
@@ -618,6 +620,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
name
=
template
.
name
name
=
template
.
name
base
=
DistutilsInfo
(
exn
=
template
)
base
=
DistutilsInfo
(
exn
=
template
)
exn_type
=
template
.
__class__
exn_type
=
template
.
__class__
ext_language
=
None
# do not override whatever the Extension says
else
:
else
:
raise
TypeError
(
pattern
)
raise
TypeError
(
pattern
)
...
@@ -661,6 +664,9 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
...
@@ -661,6 +664,9 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
depends
=
list
(
set
(
template
.
depends
).
union
(
set
(
depends
)))
depends
=
list
(
set
(
template
.
depends
).
union
(
set
(
depends
)))
kwds
[
'depends'
]
=
depends
kwds
[
'depends'
]
=
depends
if
ext_language
and
'language'
not
in
kwds
:
kwds
[
'language'
]
=
ext_language
module_list
.
append
(
exn_type
(
module_list
.
append
(
exn_type
(
name
=
module_name
,
name
=
module_name
,
sources
=
sources
,
sources
=
sources
,
...
@@ -671,7 +677,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
...
@@ -671,7 +677,7 @@ def create_extension_list(patterns, exclude=[], ctx=None, aliases=None, quiet=Fa
# This is the user-exposed entry point.
# This is the user-exposed entry point.
def
cythonize
(
module_list
,
exclude
=
[],
nthreads
=
0
,
aliases
=
None
,
quiet
=
False
,
force
=
False
,
def
cythonize
(
module_list
,
exclude
=
[],
nthreads
=
0
,
aliases
=
None
,
quiet
=
False
,
force
=
False
,
language
=
None
,
exclude_failures
=
False
,
**
options
):
exclude_failures
=
False
,
**
options
):
"""
"""
Compile a set of source modules into C/C++ files and return a list of distutils
Compile a set of source modules into C/C++ files and return a list of distutils
...
@@ -684,6 +690,11 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
...
@@ -684,6 +690,11 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
When using glob patterns, you can exclude certain module names explicitly
When using glob patterns, you can exclude certain module names explicitly
by passing them into the 'exclude' option.
by passing them into the 'exclude' option.
To globally enable C++ mode, you can pass language='c++'. Otherwise, this
will be determined at a per-file level based on compiler directives. This
affects only modules found based on file names. Extension instances passed
into cythonize() will not be changed.
For parallel compilation, set the 'nthreads' option to the number of
For parallel compilation, set the 'nthreads' option to the number of
concurrent builds.
concurrent builds.
...
@@ -711,6 +722,7 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
...
@@ -711,6 +722,7 @@ def cythonize(module_list, exclude=[], nthreads=0, aliases=None, quiet=False, fo
ctx
=
ctx
,
ctx
=
ctx
,
quiet
=
quiet
,
quiet
=
quiet
,
exclude_failures
=
exclude_failures
,
exclude_failures
=
exclude_failures
,
language
=
language
,
aliases
=
aliases
)
aliases
=
aliases
)
deps
=
create_dependency_tree
(
ctx
,
quiet
=
quiet
)
deps
=
create_dependency_tree
(
ctx
,
quiet
=
quiet
)
build_dir
=
getattr
(
options
,
'build_dir'
,
None
)
build_dir
=
getattr
(
options
,
'build_dir'
,
None
)
...
...
docs/src/userguide/wrapping_CPlusPlus.rst
View file @
f65206a8
...
@@ -137,10 +137,14 @@ together into :file:`rect.so`, which you can then import in Python using
...
@@ -137,10 +137,14 @@ together into :file:`rect.so`, which you can then import in Python using
``import rect`` (if you forget to link the :file:`Rectangle.o`, you will
``import rect`` (if you forget to link the :file:`Rectangle.o`, you will
get missing symbols while importing the library in Python).
get missing symbols while importing the library in Python).
Note that the ``language`` option has no effect on user provided Extension
objects that are passed into ``cythonize()``. It is only used for modules
found by file name (as in the example above).
The options can also be passed directly from the source file, which is
The options can also be passed directly from the source file, which is
often preferable
. Starting with version 0.17, Cython also allows to
often preferable
(and overrides any global option). Starting with
pass external source files into the ``cythonize()`` command this way.
version 0.17, Cython also allows to pass external source files into the
Here is a simplified setup.py file::
``cythonize()`` command this way.
Here is a simplified setup.py file::
from distutils.core import setup
from distutils.core import setup
from Cython.Build import cythonize
from Cython.Build import cythonize
...
...
tests/build/cpp_cythonize.srctree
View file @
f65206a8
...
@@ -10,13 +10,11 @@ from Cython.Build.Dependencies import cythonize
...
@@ -10,13 +10,11 @@ from Cython.Build.Dependencies import cythonize
from distutils.core import setup
from distutils.core import setup
setup(
setup(
ext_modules = cythonize("*.pyx"
),
ext_modules = cythonize("*.pyx", language='c++'
),
)
)
######## a.pyx ########
######## a.pyx ########
# distutils: language = c++
from libcpp.vector cimport vector
from libcpp.vector cimport vector
def use_vector(L):
def use_vector(L):
...
...
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