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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
429c0b96
Commit
429c0b96
authored
Jan 21, 2015
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:cython/cython
parents
56304494
d0c1a7a2
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
6 deletions
+62
-6
CHANGES.rst
CHANGES.rst
+2
-0
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+4
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-0
Cython/Tests/xmlrunner.py
Cython/Tests/xmlrunner.py
+3
-0
docs/src/quickstart/cythonize.rst
docs/src/quickstart/cythonize.rst
+1
-1
tests/run/closure_inlining.pyx
tests/run/closure_inlining.pyx
+27
-0
tests/run/cython3.pyx
tests/run/cython3.pyx
+15
-2
No files found.
CHANGES.rst
View file @
429c0b96
...
@@ -47,6 +47,8 @@ Other changes
...
@@ -47,6 +47,8 @@ Other changes
To try parsing your files against this grammar, use the --formal_grammar directive.
To try parsing your files against this grammar, use the --formal_grammar directive.
Experimental.
Experimental.
* ``_`` is no longer considered a cacheable builtin as it could interfere with gettext.
0.21.2 (2014-12-27)
0.21.2 (2014-12-27)
===================
===================
...
...
Cython/Compiler/Code.py
View file @
429c0b96
...
@@ -50,14 +50,15 @@ non_portable_builtins_map = {
...
@@ -50,14 +50,15 @@ non_portable_builtins_map = {
basicsize_builtins_map
=
{
basicsize_builtins_map
=
{
# builtins whose type has a different tp_basicsize than sizeof(...)
# builtins whose type has a different tp_basicsize than sizeof(...)
'PyTypeObject'
:
'PyHeapTypeObject'
,
'PyTypeObject'
:
'PyHeapTypeObject'
,
}
}
uncachable_builtins
=
[
uncachable_builtins
=
[
# builtin names that cannot be cached because they may or may not
# builtin names that cannot be cached because they may or may not
# be available at import time
# be available at import time
'WindowsError'
,
'WindowsError'
,
]
'_'
,
# e.g. gettext
]
modifier_output_mapper
=
{
modifier_output_mapper
=
{
'inline'
:
'CYTHON_INLINE'
'inline'
:
'CYTHON_INLINE'
...
...
Cython/Compiler/ExprNodes.py
View file @
429c0b96
...
@@ -5069,6 +5069,8 @@ class InlinedDefNodeCallNode(CallNode):
...
@@ -5069,6 +5069,8 @@ class InlinedDefNodeCallNode(CallNode):
return
False
return
False
if
len
(
func_type
.
args
)
!=
len
(
self
.
args
):
if
len
(
func_type
.
args
)
!=
len
(
self
.
args
):
return
False
return
False
if
func_type
.
num_kwonly_args
:
return
False
# actually wrong number of arguments
return
True
return
True
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
...
@@ -7810,6 +7812,14 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
...
@@ -7810,6 +7812,14 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
if
not
arg
.
annotation
.
type
.
is_pyobject
:
if
not
arg
.
annotation
.
type
.
is_pyobject
:
arg
.
annotation
=
arg
.
annotation
.
coerce_to_pyobject
(
env
)
arg
.
annotation
=
arg
.
annotation
.
coerce_to_pyobject
(
env
)
annotations
.
append
((
arg
.
pos
,
arg
.
name
,
arg
.
annotation
))
annotations
.
append
((
arg
.
pos
,
arg
.
name
,
arg
.
annotation
))
for
arg
in
(
self
.
def_node
.
star_arg
,
self
.
def_node
.
starstar_arg
):
if
arg
and
arg
.
annotation
:
arg
.
annotation
=
arg
.
annotation
.
analyse_types
(
env
)
if
not
arg
.
annotation
.
type
.
is_pyobject
:
arg
.
annotation
=
arg
.
annotation
.
coerce_to_pyobject
(
env
)
annotations
.
append
((
arg
.
pos
,
arg
.
name
,
arg
.
annotation
))
if
self
.
def_node
.
return_type_annotation
:
if
self
.
def_node
.
return_type_annotation
:
annotations
.
append
((
self
.
def_node
.
return_type_annotation
.
pos
,
annotations
.
append
((
self
.
def_node
.
return_type_annotation
.
pos
,
StringEncoding
.
EncodedString
(
"return"
),
StringEncoding
.
EncodedString
(
"return"
),
...
...
Cython/Tests/xmlrunner.py
View file @
429c0b96
...
@@ -212,6 +212,9 @@ class _XMLTestResult(_TextTestResult):
...
@@ -212,6 +212,9 @@ class _XMLTestResult(_TextTestResult):
for
tests
in
(
self
.
successes
,
self
.
failures
,
self
.
errors
):
for
tests
in
(
self
.
successes
,
self
.
failures
,
self
.
errors
):
for
test_info
in
tests
:
for
test_info
in
tests
:
if
not
isinstance
(
test_info
,
_TestInfo
):
print
(
"Unexpected test result type: %s"
%
test_info
)
continue
testcase
=
type
(
test_info
.
test_method
)
testcase
=
type
(
test_info
.
test_method
)
# Ignore module name if it is '__main__'
# Ignore module name if it is '__main__'
...
...
docs/src/quickstart/cythonize.rst
View file @
429c0b96
...
@@ -62,7 +62,7 @@ With additional type declarations, this might look like::
...
@@ -62,7 +62,7 @@ With additional type declarations, this might look like::
Since the iterator variable ``i`` is typed with C semantics, the for-loop will be compiled
Since the iterator variable ``i`` is typed with C semantics, the for-loop will be compiled
to pure C code. Typing ``a``, ``s`` and ``dx`` is important as they are involved
to pure C code. Typing ``a``, ``s`` and ``dx`` is important as they are involved
in arithmetic within
g
the for-loop; typing ``b`` and ``N`` makes less of a
in arithmetic within the for-loop; typing ``b`` and ``N`` makes less of a
difference, but in this case it is not much extra work to be
difference, but in this case it is not much extra work to be
consistent and type the entire function.
consistent and type the entire function.
...
...
tests/run/closure_inlining.pyx
View file @
429c0b96
...
@@ -37,6 +37,9 @@ def test_func_signature(a):
...
@@ -37,6 +37,9 @@ def test_func_signature(a):
"""
"""
>>> test_func_signature(Foo())
>>> test_func_signature(Foo())
<Foo>
<Foo>
>>> test_func_signature(123)
Traceback (most recent call last):
TypeError: Cannot convert int to closure_inlining.Foo
"""
"""
def
inner
(
Foo
a
):
def
inner
(
Foo
a
):
...
@@ -49,6 +52,9 @@ def test_func_signature2(a, b):
...
@@ -49,6 +52,9 @@ def test_func_signature2(a, b):
"""
"""
>>> test_func_signature2(Foo(), 123)
>>> test_func_signature2(Foo(), 123)
(<Foo>, 123)
(<Foo>, 123)
>>> test_func_signature2(321, 123)
Traceback (most recent call last):
TypeError: Cannot convert int to closure_inlining.Foo
"""
"""
def
inner
(
Foo
a
,
b
):
def
inner
(
Foo
a
,
b
):
...
@@ -66,6 +72,27 @@ def test_defaults(a, b):
...
@@ -66,6 +72,27 @@ def test_defaults(a, b):
return
a
,
b
,
c
return
a
,
b
,
c
return
inner
(
a
)
return
inner
(
a
)
@
cython
.
test_assert_path_exists
(
'//SimpleCallNode'
)
def
test_kwonly_args
(
a
,
b
):
"""
>>> test_kwonly_args(1, 2)
(1, 2, 123)
"""
def
inner
(
a
,
b
=
b
,
*
,
c
=
123
):
return
a
,
b
,
c
return
inner
(
a
)
@
cython
.
test_assert_path_exists
(
'//SimpleCallNode'
)
def
test_kwonly_args_missing
(
a
,
b
):
"""
>>> test_kwonly_args_missing(1, 2)
Traceback (most recent call last):
TypeError: inner() needs keyword-only argument c
"""
def
inner
(
a
,
b
=
b
,
*
,
c
):
return
a
,
b
,
c
return
inner
(
a
)
@
cython
.
test_assert_path_exists
(
'//SimpleCallNode'
)
@
cython
.
test_assert_path_exists
(
'//SimpleCallNode'
)
def
test_starred
(
a
):
def
test_starred
(
a
):
"""
"""
...
...
tests/run/cython3.pyx
View file @
429c0b96
# cython: language_level=3
# cython: language_level=3
, binding=True
# mode: run
# mode: run
# tag: generators, python3, exceptions
# tag: generators, python3, exceptions
...
@@ -437,11 +437,24 @@ def int_literals():
...
@@ -437,11 +437,24 @@ def int_literals():
print
(
cython
.
typeof
(
1
UL
))
print
(
cython
.
typeof
(
1
UL
))
print
(
cython
.
typeof
(
10000000000000
UL
))
print
(
cython
.
typeof
(
10000000000000
UL
))
def
annotation_syntax
(
a
:
"test new test"
,
b
:
"other"
=
2
)
->
"ret"
:
def
annotation_syntax
(
a
:
"test new test"
,
b
:
"other"
=
2
,
*
args
:
"ARGS"
,
**
kwargs
:
"KWARGS"
)
->
"ret"
:
"""
"""
>>> annotation_syntax(1)
>>> annotation_syntax(1)
3
3
>>> annotation_syntax(1,3)
>>> annotation_syntax(1,3)
4
4
>>> len(annotation_syntax.__annotations__)
5
>>> print(annotation_syntax.__annotations__['a'])
test new test
>>> print(annotation_syntax.__annotations__['b'])
other
>>> print(annotation_syntax.__annotations__['args'])
ARGS
>>> print(annotation_syntax.__annotations__['kwargs'])
KWARGS
>>> print(annotation_syntax.__annotations__['return'])
ret
"""
"""
return
a
+
b
return
a
+
b
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