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
e9036d3a
Commit
e9036d3a
authored
Feb 11, 2015
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.22.x' into release-candidate
parents
1fb644d6
73022d11
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
194 additions
and
53 deletions
+194
-53
CHANGES.rst
CHANGES.rst
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-5
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-3
Cython/Utility/Profile.c
Cython/Utility/Profile.c
+54
-38
docs/src/userguide/buffer.rst
docs/src/userguide/buffer.rst
+5
-5
runtests.py
runtests.py
+1
-0
tests/bugs.txt
tests/bugs.txt
+2
-0
tests/run/carray_coercion.pyx
tests/run/carray_coercion.pyx
+51
-0
tests/run/coverage.srctree
tests/run/coverage.srctree
+64
-0
tests/run/numpy_math.pyx
tests/run/numpy_math.pyx
+2
-1
No files found.
CHANGES.rst
View file @
e9036d3a
...
...
@@ -58,7 +58,7 @@ Other changes
* ``_`` is no longer considered a cacheable builtin as it could interfere with
gettext.
* Cythonize-computed metadata now cached in the generate C files.
* Cythonize-computed metadata now cached in the generate
d
C files.
* Several corrections and extensions in numpy, cpython, and libcpp pxd files.
...
...
Cython/Compiler/ExprNodes.py
View file @
e9036d3a
...
...
@@ -6767,6 +6767,13 @@ class ListNode(SequenceNode):
else
:
offset
=
''
for
i
,
arg
in
enumerate
(
self
.
args
):
if
arg
.
type
.
is_array
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"IncludeStringH"
,
"StringTools.c"
))
code
.
putln
(
"memcpy(&(%s[%s%s]), %s, sizeof(%s[0]));"
%
(
self
.
result
(),
i
,
offset
,
arg
.
result
(),
self
.
result
()
))
else
:
code
.
putln
(
"%s[%s%s] = %s;"
%
(
self
.
result
(),
i
,
...
...
Cython/Compiler/ModuleNode.py
View file @
e9036d3a
...
...
@@ -552,10 +552,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"/* Generated by Cython %s */"
%
Version
.
watermark
)
code
.
putln
(
""
)
if
metadata
:
code
.
putln
(
"/* Cython Metadata */"
)
code
.
putln
(
"/*"
)
code
.
putln
(
"/* BEGIN: Cython Metadata"
)
code
.
putln
(
json
.
dumps
(
metadata
,
indent
=
4
))
code
.
putln
(
"*/"
)
code
.
putln
(
"
END: Cython Metadata
*/"
)
code
.
putln
(
""
)
code
.
putln
(
"#define PY_SSIZE_T_CLEAN"
)
...
...
Cython/Utility/Profile.c
View file @
e9036d3a
...
...
@@ -35,20 +35,25 @@
#endif
#define __Pyx_TraceDeclarations(codeobj) \
static PyCodeObject *$frame_code_cname = NULL;
if (codeobj != NULL) $frame_code_cname = (PyCodeObject*) codeobj;
\
static PyCodeObject *$frame_code_cname = NULL;
\
CYTHON_FRAME_MODIFIER PyFrameObject *$frame_cname = NULL; \
int __Pyx_use_tracing = 0;
int __Pyx_use_tracing = 0; \
if (codeobj) $frame_code_cname = (PyCodeObject*) codeobj;
#define __Pyx_TraceCall(funcname, srcfile, firstlineno) \
if (unlikely(PyThreadState_GET()->use_tracing && \
(PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc)))) { \
{ PyThreadState* tstate = PyThreadState_GET(); \
if (unlikely(tstate->use_tracing) && !tstate->tracing && \
(tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) { \
__Pyx_use_tracing = __Pyx_TraceSetupAndCall(&$frame_code_cname, &$frame_cname, funcname, srcfile, firstlineno); \
} \
}
#define __Pyx_TraceException() \
if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && \
(PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc))) { \
if (likely(!__Pyx_use_tracing)); else { \
PyThreadState* tstate = PyThreadState_GET(); \
if (tstate->use_tracing && \
(tstate->c_profilefunc || (CYTHON_TRACE && tstate->c_tracefunc))) { \
tstate->tracing++; \
tstate->use_tracing = 0; \
PyObject *exc_info = __Pyx_GetExceptionTuple(); \
if (exc_info) { \
...
...
@@ -60,11 +65,15 @@
Py_DECREF(exc_info); \
} \
tstate->use_tracing = 1; \
tstate->tracing--; \
} \
}
#define __Pyx_TraceReturn(result) \
if (
unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing) {
\
if (
likely(!__Pyx_use_tracing)); else {
\
PyThreadState* tstate = PyThreadState_GET(); \
if (tstate->use_tracing) { \
tstate->tracing++; \
tstate->use_tracing = 0; \
if (CYTHON_TRACE && tstate->c_tracefunc) \
tstate->c_tracefunc( \
...
...
@@ -74,6 +83,8 @@
tstate->c_profileobj, $frame_cname, PyTrace_RETURN, (PyObject*)result); \
CYTHON_FRAME_DEL; \
tstate->use_tracing = 1; \
tstate->tracing--; \
} \
}
static
PyCodeObject
*
__Pyx_createFrameCodeObject
(
const
char
*
funcname
,
const
char
*
srcfile
,
int
firstlineno
);
/*proto*/
...
...
@@ -90,12 +101,16 @@
#if CYTHON_TRACE
#define __Pyx_TraceLine(lineno) \
if (
unlikely(__Pyx_use_tracing) && unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_tracefunc)) {
\
if (
likely(!__Pyx_use_tracing)); else {
\
PyThreadState* tstate = PyThreadState_GET(); \
if (unlikely(tstate->use_tracing && tstate->c_tracefunc)) { \
$frame_cname->f_lineno = lineno; \
tstate->tracing++; \
tstate->use_tracing = 0; \
tstate->c_tracefunc(tstate->c_traceobj, $frame_cname, PyTrace_LINE, NULL); \
tstate->use_tracing = 1; \
tstate->tracing--; \
} \
}
#else
#define __Pyx_TraceLine(lineno)
...
...
@@ -136,17 +151,18 @@ static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
#endif
}
(
*
frame
)
->
f_lineno
=
firstlineno
;
retval
=
1
;
tstate
->
tracing
++
;
tstate
->
use_tracing
=
0
;
#if CYTHON_TRACE
if
(
tstate
->
c_tracefunc
)
tstate
->
c_tracefunc
(
tstate
->
c_traceobj
,
*
frame
,
PyTrace_CALL
,
NULL
);
if
(
!
tstate
->
c_profilefunc
)
retval
=
1
;
else
retval
=
tstate
->
c_tracefunc
(
tstate
->
c_traceobj
,
*
frame
,
PyTrace_CALL
,
NULL
)
==
0
;
if
(
retval
&&
tstate
->
c_profilefunc
)
#endif
retval
=
tstate
->
c_profilefunc
(
tstate
->
c_profileobj
,
*
frame
,
PyTrace_CALL
,
NULL
)
==
0
;
tstate
->
use_tracing
=
(
tstate
->
c_profilefunc
||
(
CYTHON_TRACE
&&
tstate
->
c_tracefunc
));
tstate
->
tracing
--
;
return
tstate
->
use_tracing
&&
retval
;
}
...
...
docs/src/userguide/buffer.rst
View file @
e9036d3a
...
...
@@ -66,23 +66,23 @@ which Cython handles specially.
self.shape[1] = self.ncols
# Stride 1 is the distance, in bytes, between two items in a row;
# this is the distance between two adja
nce
items in the vector.
# this is the distance between two adja
cent
items in the vector.
# Stride 0 is the distance between the first elements of adjacent rows.
self.strides[1] = <Py_ssize_t>( <char *>&(self.v[1])
- <char *>&(self.v[0]))
self.strides[0] = self.ncols * self.strides[1]
buffer.buf = <char *>&(self.v[0])
buffer.format = 'f'
buffer.internal = NULL
buffer.format = 'f'
# float
buffer.internal = NULL
# see References
buffer.itemsize = itemsize
buffer.len = self.v.size() * itemsize
buffer.len = self.v.size() * itemsize
# product(shape) * itemsize
buffer.ndim = 2
buffer.obj = self
buffer.readonly = 0
buffer.shape = self.shape
buffer.strides = self.strides
buffer.suboffsets = NULL
buffer.suboffsets = NULL
# for pointer arrays only
def __releasebuffer__(self, Py_buffer *buffer):
pass
...
...
runtests.py
View file @
e9036d3a
...
...
@@ -102,6 +102,7 @@ EXT_DEP_MODULES = {
'tag:pstats'
:
'pstats'
,
'tag:posix'
:
'posix'
,
'tag:array'
:
'array'
,
'tag:coverage'
:
'coverage'
,
'tag:ipython'
:
'IPython'
,
'tag:jedi'
:
'jedi'
,
}
...
...
tests/bugs.txt
View file @
e9036d3a
...
...
@@ -14,6 +14,8 @@ inherited_final_method
tryfinallychaining # also see FIXME in "yield_from_pep380" test
cimport_alias_subclass
coverage # depends on newer coverage.py version
# CPython regression tests that don't current work:
pyregr.test_signal
pyregr.test_capi
...
...
tests/run/carray_coercion.pyx
View file @
e9036d3a
...
...
@@ -67,6 +67,57 @@ def from_int_array_array():
return
v
def
assign_int_array_array
():
"""
>>> assign_int_array_array()
[[11, 12, 13], [21, 22, 23]]
"""
cdef
int
[
2
][
3
]
v
=
[[
11
,
12
,
13
],
[
21
,
22
,
23
]]
return
v
def
assign_int_array_array_from_tuples
():
"""
>>> assign_int_array_array_from_tuples()
[[11, 12, 13], [21, 22, 23]]
"""
cdef
int
[
2
][
3
]
v
=
([
11
,
12
,
13
],
[
21
,
22
,
23
])
return
v
''' FIXME: this currently crashes:
def assign_int_array_array_from_tuples():
"""
>>> assign_int_array_array_from_tuples()
[[11, 12, 13], [21, 22, 23]]
"""
cdef int[2][3] v = ((11, 12, 13), (21, 22, 23))
return v
'''
def
build_from_list_of_arrays
():
"""
>>> build_from_list_of_arrays()
[[11, 12, 13], [21, 22, 23]]
"""
cdef
int
[
3
]
x
=
[
11
,
12
,
13
]
cdef
int
[
3
]
y
=
[
21
,
22
,
23
]
cdef
int
[
2
][
3
]
v
=
[
x
,
y
]
return
v
def
build_from_tuple_of_arrays
():
"""
>>> build_from_tuple_of_arrays()
[[11, 12, 13], [21, 22, 23]]
"""
cdef
int
[
3
]
x
=
[
11
,
12
,
13
]
cdef
int
[
3
]
y
=
[
21
,
22
,
23
]
cdef
int
[
2
][
3
]
v
=
(
x
,
y
)
return
v
ctypedef
struct
MyStructType
:
int
x
double
y
...
...
tests/run/coverage.srctree
0 → 100644
View file @
e9036d3a
# mode: run
# tag: coverage,trace
"""
PYTHON setup.py build_ext -i
PYTHON coverage_test.py
"""
######## setup.py ########
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize('coverage_test_cy.py'))
######## coverage_test_cy.py ########
# cython: linetrace=True
# distutils: define_macros=CYTHON_TRACE=1
def func1(a, b):
x = 1 # 5
c = func2(a) + b # 6
return x + c # 7
def func2(a):
return a * 2 # 11
######## coverage_test.py ########
try:
# io.StringIO in Py2.x cannot handle str ...
from StringIO import StringIO
except ImportError:
from io import StringIO
from coverage import coverage
import coverage_test_cy
def run_coverage():
cov = coverage()
cov.start()
assert coverage_test_cy.func1(1, 2) == 5
assert coverage_test_cy.func2(2) == 4
cov.stop()
out = StringIO()
cov.report([coverage_test_cy], file=out)
lines = out.getvalue().splitlines()
assert any('coverage_test_cy' in line for line in lines), "coverage_test_cy not found in coverage"
mod_file, exec_lines, excl_lines, missing_lines, _ = cov.analysis2(coverage_test_cy)
assert 'coverage_test_cy' in mod_file
executed = set(exec_lines) - set(missing_lines)
assert all(line in executed for line in [5, 6, 7, 11]), '%s / %s' % (exec_lines, missing_lines)
if __name__ == '__main__':
run_coverage()
tests/run/numpy_math.pyx
View file @
e9036d3a
...
...
@@ -37,7 +37,8 @@ def test_fp_classif():
assert
not
npmath
.
isnan
(
d_zero
)
assert
not
npmath
.
isnan
(
f_zero
)
assert
npmath
.
isinf
(
npmath
.
INFINITY
)
assert
npmath
.
isinf
(
npmath
.
INFINITY
)
==
1
assert
npmath
.
isinf
(
-
npmath
.
INFINITY
)
==
-
1
assert
npmath
.
isnan
(
npmath
.
NAN
)
assert
npmath
.
signbit
(
npmath
.
copysign
(
1.
,
-
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