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
9bb67b49
Commit
9bb67b49
authored
Nov 07, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more builtin method cleanups
parent
96925842
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
25 deletions
+21
-25
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+3
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+0
-18
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+9
-1
tests/run/unicodemethods.pyx
tests/run/unicodemethods.pyx
+9
-4
No files found.
Cython/Compiler/Builtin.py
View file @
9bb67b49
...
@@ -108,7 +108,8 @@ builtin_types_table = [
...
@@ -108,7 +108,8 @@ builtin_types_table = [
(
"bytes"
,
"PyBytes_Type"
,
[]),
(
"bytes"
,
"PyBytes_Type"
,
[]),
(
"str"
,
"PyString_Type"
,
[]),
(
"str"
,
"PyString_Type"
,
[]),
(
"unicode"
,
"PyUnicode_Type"
,
[]),
(
"unicode"
,
"PyUnicode_Type"
,
[(
"join"
,
"TO"
,
"T"
,
"PyUnicode_Join"
),
]),
(
"tuple"
,
"PyTuple_Type"
,
[]),
(
"tuple"
,
"PyTuple_Type"
,
[]),
...
@@ -120,7 +121,7 @@ builtin_types_table = [
...
@@ -120,7 +121,7 @@ builtin_types_table = [
(
"dict"
,
"PyDict_Type"
,
[(
"items"
,
"T"
,
"O"
,
"PyDict_Items"
),
(
"dict"
,
"PyDict_Type"
,
[(
"items"
,
"T"
,
"O"
,
"PyDict_Items"
),
(
"keys"
,
"T"
,
"O"
,
"PyDict_Keys"
),
(
"keys"
,
"T"
,
"O"
,
"PyDict_Keys"
),
(
"values"
,
"T"
,
"O"
,
"PyDict_Values"
),
(
"values"
,
"T"
,
"O"
,
"PyDict_Values"
),
(
"copy"
,
"T"
,
"
O
"
,
"PyDict_Copy"
)]),
(
"copy"
,
"T"
,
"
T
"
,
"PyDict_Copy"
)]),
(
"slice"
,
"PySlice_Type"
,
[]),
(
"slice"
,
"PySlice_Type"
,
[]),
# ("file", "PyFile_Type", []), # not in Py3
# ("file", "PyFile_Type", []), # not in Py3
...
...
Cython/Compiler/Optimize.py
View file @
9bb67b49
...
@@ -2187,24 +2187,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
...
@@ -2187,24 +2187,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
node
,
"PyUnicode_Splitlines"
,
self
.
PyUnicode_Splitlines_func_type
,
node
,
"PyUnicode_Splitlines"
,
self
.
PyUnicode_Splitlines_func_type
,
'splitlines'
,
is_unbound_method
,
args
)
'splitlines'
,
is_unbound_method
,
args
)
PyUnicode_Join_func_type
=
PyrexTypes
.
CFuncType
(
Builtin
.
unicode_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"sep"
,
Builtin
.
unicode_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"iterable"
,
PyrexTypes
.
py_object_type
,
None
),
])
def
_handle_simple_method_unicode_join
(
self
,
node
,
args
,
is_unbound_method
):
"""Replace unicode.join(...) by a direct call to the
corresponding C-API function.
"""
if
len
(
args
)
!=
2
:
self
.
_error_wrong_arg_count
(
'unicode.join'
,
node
,
args
,
2
)
return
node
return
self
.
_substitute_method_call
(
node
,
"PyUnicode_Join"
,
self
.
PyUnicode_Join_func_type
,
'join'
,
is_unbound_method
,
args
)
PyUnicode_Split_func_type
=
PyrexTypes
.
CFuncType
(
PyUnicode_Split_func_type
=
PyrexTypes
.
CFuncType
(
Builtin
.
list_type
,
[
Builtin
.
list_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"str"
,
Builtin
.
unicode_type
,
None
),
PyrexTypes
.
CFuncTypeArg
(
"str"
,
Builtin
.
unicode_type
,
None
),
...
...
Cython/Compiler/TypeSlots.py
View file @
9bb67b49
...
@@ -64,6 +64,7 @@ class Signature(object):
...
@@ -64,6 +64,7 @@ class Signature(object):
error_value_map
=
{
error_value_map
=
{
'O'
:
"NULL"
,
'O'
:
"NULL"
,
'T'
:
"NULL"
,
'i'
:
"-1"
,
'i'
:
"-1"
,
'b'
:
"-1"
,
'b'
:
"-1"
,
'l'
:
"-1"
,
'l'
:
"-1"
,
...
@@ -91,6 +92,10 @@ class Signature(object):
...
@@ -91,6 +92,10 @@ class Signature(object):
# argument is 'self' for methods or 'class' for classmethods
# argument is 'self' for methods or 'class' for classmethods
return
self
.
fixed_arg_format
[
i
]
==
'T'
return
self
.
fixed_arg_format
[
i
]
==
'T'
def
returns_self_type
(
self
):
# return type is same as 'self' argument type
return
self
.
ret_format
==
'T'
def
fixed_arg_type
(
self
,
i
):
def
fixed_arg_type
(
self
,
i
):
return
self
.
format_map
[
self
.
fixed_arg_format
[
i
]]
return
self
.
format_map
[
self
.
fixed_arg_format
[
i
]]
...
@@ -110,7 +115,10 @@ class Signature(object):
...
@@ -110,7 +115,10 @@ class Signature(object):
else
:
else
:
arg_type
=
self
.
fixed_arg_type
(
i
)
arg_type
=
self
.
fixed_arg_type
(
i
)
args
.
append
(
PyrexTypes
.
CFuncTypeArg
(
""
,
arg_type
,
None
))
args
.
append
(
PyrexTypes
.
CFuncTypeArg
(
""
,
arg_type
,
None
))
ret_type
=
self
.
return_type
()
if
self_arg_override
is
not
None
and
self
.
returns_self_type
():
ret_type
=
self_arg_override
.
type
else
:
ret_type
=
self
.
return_type
()
exc_value
=
self
.
exception_value
()
exc_value
=
self
.
exception_value
()
return
PyrexTypes
.
CFuncType
(
ret_type
,
args
,
exception_value
=
exc_value
)
return
PyrexTypes
.
CFuncType
(
ret_type
,
args
,
exception_value
=
exc_value
)
...
...
tests/run/unicodemethods.pyx
View file @
9bb67b49
...
@@ -180,9 +180,12 @@ pipe_sep = u'|'
...
@@ -180,9 +180,12 @@ pipe_sep = u'|'
@
cython
.
test_fail_if_path_exists
(
@
cython
.
test_fail_if_path_exists
(
"//CoerceToPyTypeNode"
,
"//CoerceFromPyTypeNode"
,
"//CoerceToPyTypeNode"
,
"//CoerceFromPyTypeNode"
,
"//CastNode"
,
"//TypecastNode"
)
"//CastNode"
,
"//TypecastNode"
,
"//SimpleCallNode//AttributeNode[@is_py_attr = true]"
)
@
cython
.
test_assert_path_exists
(
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
)
"//SimpleCallNode"
,
"//SimpleCallNode//NoneCheckNode"
,
"//SimpleCallNode//AttributeNode[@is_py_attr = false]"
)
def
join
(
unicode
sep
,
l
):
def
join
(
unicode
sep
,
l
):
"""
"""
>>> l = text.split()
>>> l = text.split()
...
@@ -197,9 +200,11 @@ def join(unicode sep, l):
...
@@ -197,9 +200,11 @@ def join(unicode sep, l):
@
cython
.
test_fail_if_path_exists
(
@
cython
.
test_fail_if_path_exists
(
"//CoerceToPyTypeNode"
,
"//CoerceFromPyTypeNode"
,
"//CoerceToPyTypeNode"
,
"//CoerceFromPyTypeNode"
,
"//CastNode"
,
"//TypecastNode"
,
"//NoneCheckNode"
)
"//CastNode"
,
"//TypecastNode"
,
"//NoneCheckNode"
,
"//SimpleCallNode//AttributeNode[@is_py_attr = true]"
)
@
cython
.
test_assert_path_exists
(
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
)
"//SimpleCallNode"
,
"//SimpleCallNode//AttributeNode[@is_py_attr = false]"
)
def
join_sep
(
l
):
def
join_sep
(
l
):
"""
"""
>>> l = text.split()
>>> l = text.split()
...
...
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