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
Boxiang Sun
cython
Commits
46bbbaba
Commit
46bbbaba
authored
Dec 21, 2010
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master'
parents
3c2d9b37
e3c9a786
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
43 deletions
+83
-43
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+14
-8
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+1
-2
Cython/Includes/cpython/buffer.pxd
Cython/Includes/cpython/buffer.pxd
+3
-3
tests/run/delete.pyx
tests/run/delete.pyx
+53
-24
tests/run/isinstance.pyx
tests/run/isinstance.pyx
+8
-5
No files found.
Cython/Compiler/ExprNodes.py
View file @
46bbbaba
...
...
@@ -2612,6 +2612,7 @@ class SliceIndexNode(ExprNode):
self
.
start_code
(),
self
.
stop_code
()))
self
.
generate_subexpr_disposal_code
(
code
)
self
.
free_subexpr_temps
(
code
)
def
generate_slice_guard_code
(
self
,
code
,
target_size
):
if
not
self
.
base
.
type
.
is_array
:
...
...
Cython/Compiler/ModuleNode.py
View file @
46bbbaba
...
...
@@ -579,6 +579,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
...
...
Cython/Compiler/Nodes.py
View file @
46bbbaba
...
...
@@ -2081,7 +2081,7 @@ class DefNode(FuncDefNode):
# staticmethod() was overridden - not much we can do here ...
self
.
is_staticmethod
=
False
if
self
.
name
==
'__new__'
:
if
self
.
name
==
'__new__'
and
env
.
is_py_class_scope
:
self
.
is_staticmethod
=
1
self
.
analyse_argument_types
(
env
)
...
...
Cython/Compiler/Optimize.py
View file @
46bbbaba
...
...
@@ -1986,20 +1986,26 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
test_nodes
=
[]
env
=
self
.
current_env
()
for
test_type_node
in
types
:
if
not
test_type_node
.
entry
:
return
node
builtin_type
=
None
if
isinstance
(
test_type_node
,
ExprNodes
.
NameNode
):
if
test_type_node
.
entry
:
entry
=
env
.
lookup
(
test_type_node
.
entry
.
name
)
if
not
entry
or
not
entry
.
type
or
not
entry
.
type
.
is_builtin_type
:
return
node
if
entry
and
entry
.
type
and
entry
.
type
.
is_builtin_type
:
builtin_type
=
entry
.
type
if
builtin_type
and
builtin_type
is
not
Builtin
.
type_type
:
type_check_function
=
entry
.
type
.
type_check_function
(
exact
=
False
)
if
not
type_check_function
:
type_check_args
=
[
arg
]
elif
test_type_node
.
type
is
Builtin
.
type_type
:
type_check_function
=
'__Pyx_TypeCheck'
type_check_args
=
[
arg
,
test_type_node
]
else
:
return
node
if
type_check_function
not
in
tests
:
tests
.
append
(
type_check_function
)
test_nodes
.
append
(
ExprNodes
.
PythonCapiCallNode
(
test_type_node
.
pos
,
type_check_function
,
self
.
Py_type_check_func_type
,
args
=
[
arg
]
,
args
=
type_check_args
,
is_temp
=
True
,
))
...
...
Cython/Compiler/Symtab.py
View file @
46bbbaba
...
...
@@ -1583,9 +1583,8 @@ class CClassScope(ClassScope):
if
name
in
(
'__eq__'
,
'__ne__'
,
'__lt__'
,
'__gt__'
,
'__le__'
,
'__ge__'
):
error
(
pos
,
"Special method %s must be implemented via __richcmp__"
%
name
)
if
name
==
"__new__"
:
warning
(
pos
,
"__new__ method of extension type will change semantics "
error
(
pos
,
"__new__ method of extension type will change semantics "
"in a future version of Pyrex and Cython. Use __cinit__ instead."
)
name
=
EncodedString
(
"__cinit__"
)
entry
=
self
.
declare_var
(
name
,
py_object_type
,
pos
,
visibility
=
'extern'
)
special_sig
=
get_special_method_signature
(
name
)
if
special_sig
:
...
...
Cython/Includes/cpython/buffer.pxd
View file @
46bbbaba
...
...
@@ -49,9 +49,9 @@ cdef extern from "Python.h":
# 0 is returned on success and -1 on error.
void
PyBuffer_Release
(
object
obj
,
object
view
)
# Release the buffer view
over obj. This should be called when the
#
buffer
is no longer being used as it may free memory from it.
void
PyBuffer_Release
(
Py_buffer
*
view
)
# Release the buffer view
. This should be called when the buffer
# is no longer being used as it may free memory from it.
void
*
PyBuffer_GetPointer
(
Py_buffer
*
view
,
Py_ssize_t
*
indices
)
# ??
...
...
tests/run/delete.pyx
View file @
46bbbaba
"""
>>> a = A()
>>> a.f()
[2, 1]
>>> a.g()
(False, True)
>>> del_item({1: 'a', 2: 'b'}, 1)
{2: 'b'}
>>> del_item(list(range(10)), 2)
[0, 1, 3, 4, 5, 6, 7, 8, 9]
>>> del_dict({1: 'a', 2: 'b'}, 1)
{2: 'b'}
>>> del_list(list(range(5)), 3)
[0, 1, 2, 4]
>>> del_int(list(range(5)), 3)
[0, 1, 2, 4]
>>> del_list_int(list(range(5)), 3)
[0, 1, 2, 4]
>>> del_int({-1: 'neg', 1: 'pos'}, -1)
{1: 'pos'}
"""
class
A
:
class
A
(
object
):
"""
>>> a = A()
>>> a.f()
[2, 1]
>>> a.g()
(False, True)
"""
def
f
(
self
):
self
.
refs
=
[
3
,
2
,
1
]
del
self
.
refs
[
0
]
...
...
@@ -33,21 +18,65 @@ class A:
return
(
hasattr
(
self
,
u"a"
),
hasattr
(
self
,
u"g"
))
def
del_item
(
L
,
o
):
"""
>>> del_item({1: 'a', 2: 'b'}, 1)
{2: 'b'}
>>> del_item(list(range(10)), 2)
[0, 1, 3, 4, 5, 6, 7, 8, 9]
"""
del
L
[
o
]
return
L
def
del_dict
(
dict
D
,
o
):
"""
>>> del_dict({1: 'a', 2: 'b'}, 1)
{2: 'b'}
"""
del
D
[
o
]
return
D
def
del_list
(
list
L
,
o
):
"""
>>> del_list(list(range(5)), 3)
[0, 1, 2, 4]
"""
del
L
[
o
]
return
L
def
del_int
(
L
,
int
i
):
"""
>>> del_int(list(range(5)), 3)
[0, 1, 2, 4]
>>> del_int({-1: 'neg', 1: 'pos'}, -1)
{1: 'pos'}
"""
del
L
[
i
]
return
L
def
del_list_int
(
L
,
int
i
):
"""
>>> del_list_int(list(range(5)), 3)
[0, 1, 2, 4]
"""
del
L
[
i
]
return
L
def
del_temp_slice
(
a
):
"""
>>> class A(object):
... attr = [1,2,3]
>>> a = A()
>>> a.attr
[1, 2, 3]
>>> del_temp_slice(a)
[]
>>> a.attr
[]
>>> del_temp_slice(a)
[]
>>> a.attr
[]
"""
while
a
.
attr
:
del
a
.
attr
[:]
return
a
.
attr
tests/run/isinstance.pyx
View file @
46bbbaba
...
...
@@ -48,6 +48,11 @@ def test_optimised():
assert
isinstance
(
complex
(),
complex
)
assert
not
isinstance
(
u"foo"
,
int
)
assert
isinstance
(
A
,
type
)
assert
isinstance
(
A
(),
A
)
cdef
type
typed_type
=
A
assert
isinstance
(
A
(),
typed_type
)
cdef
object
untyped_type
=
A
assert
isinstance
(
A
(),
<
type
>
untyped_type
)
return
True
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
)
...
...
@@ -59,13 +64,11 @@ def test_optimised_tuple():
>>> test_optimised_tuple()
True
"""
assert
isinstance
(
int
(),
(
int
,
long
,
float
,
bytes
,
str
,
unicode
,
tuple
,
list
,
dict
,
set
,
slice
))
assert
isinstance
(
list
(),
(
int
,
long
,
float
,
bytes
,
str
,
unicode
,
tuple
,
list
,
dict
,
set
,
slice
))
assert
isinstance
(
int
(),
(
int
,
long
,
float
,
bytes
,
str
,
unicode
,
tuple
,
list
,
dict
,
set
,
slice
,
A
))
assert
isinstance
(
list
(),
(
int
,
long
,
float
,
bytes
,
str
,
unicode
,
tuple
,
list
,
dict
,
set
,
slice
,
A
))
assert
isinstance
(
A
(),
(
int
,
long
,
float
,
bytes
,
str
,
unicode
,
tuple
,
list
,
dict
,
set
,
slice
,
A
))
return
True
@
cython
.
test_assert_path_exists
(
'//SimpleCallNode//SimpleCallNode'
)
@
cython
.
test_fail_if_path_exists
(
'//SimpleCallNode//PythonCapiCallNode'
,
'//PythonCapiCallNode//SimpleCallNode'
)
def
test_custom
():
"""
>>> test_custom()
...
...
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