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
41ad8407
Commit
41ad8407
authored
May 06, 2017
by
scoder
Committed by
GitHub
May 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1648 from da-woods/cmplx_abs
Now uses specialised functions for complex abs
parents
503a62cb
56b054b5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+17
-17
tests/run/builtin_abs.pyx
tests/run/builtin_abs.pyx
+11
-0
No files found.
Cython/Compiler/Builtin.py
View file @
41ad8407
...
...
@@ -95,27 +95,27 @@ builtin_function_table = [
is_strict_signature
=
True
),
BuiltinFunction
(
'abs'
,
"f"
,
"f"
,
"fabsf"
,
is_strict_signature
=
True
),
BuiltinFunction
(
'abs'
,
None
,
None
,
"__Pyx_abs_int"
,
utility_code
=
UtilityCode
.
load
(
"abs_int"
,
"Builtins.c"
),
]
+
list
(
# uses getattr to get PyrexTypes.c_uint_type etc to allow easy iteration over a list
BuiltinFunction
(
'abs'
,
None
,
None
,
"__Pyx_abs_{0}"
.
format
(
t
),
utility_code
=
UtilityCode
.
load
(
"abs_{0}"
.
format
(
t
),
"Builtins.c"
),
func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_uint_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"arg"
,
PyrexTypes
.
c_int_type
,
None
)
getattr
(
PyrexTypes
,
"c_u{0}_type"
.
format
(
t
))
,
[
PyrexTypes
.
CFuncTypeArg
(
"arg"
,
getattr
(
PyrexTypes
,
"c_{0}_type"
.
format
(
t
))
,
None
)
],
is_strict_signature
=
True
)),
BuiltinFunction
(
'abs'
,
None
,
None
,
"__Pyx_abs_long"
,
utility_code
=
UtilityCode
.
load
(
"abs_long"
,
"Builtins.c"
),
is_strict_signature
=
True
,
nogil
=
True
))
for
t
in
(
"int"
,
"long"
,
"longlong"
)
)
+
list
(
BuiltinFunction
(
'abs'
,
None
,
None
,
"__Pyx_c_abs{0}"
.
format
(
t
.
funcsuffix
),
func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_ulong
_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"arg"
,
PyrexTypes
.
c_long_type
,
None
)
t
.
real
_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"arg"
,
t
,
None
)
],
is_strict_signature
=
True
)),
BuiltinFunction
(
'abs'
,
None
,
None
,
"__Pyx_abs_longlong"
,
utility_code
=
UtilityCode
.
load
(
"abs_longlong"
,
"Builtins.c"
),
func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
c_ulonglong_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"arg"
,
PyrexTypes
.
c_longlong_type
,
None
)
],
is_strict_signature
=
True
)),
is_strict_signature
=
True
,
nogil
=
True
))
for
t
in
(
PyrexTypes
.
c_float_complex_type
,
PyrexTypes
.
c_double_complex_type
,
PyrexTypes
.
c_longdouble_complex_type
)
)
+
[
BuiltinFunction
(
'abs'
,
"O"
,
"O"
,
"PyNumber_Absolute"
),
#('all', "", "", ""),
#('any', "", "", ""),
...
...
tests/run/builtin_abs.pyx
View file @
41ad8407
...
...
@@ -120,3 +120,14 @@ def float_abs(float a):
5.5
"""
return
abs
(
a
)
@
cython
.
test_assert_path_exists
(
"//ReturnStatNode//NameNode[@entry.name = 'abs']"
,
"//ReturnStatNode//NameNode[@entry.cname = '__Pyx_c_abs_double']"
)
def
complex_abs
(
complex
a
):
"""
>>> complex_abs(-5j)
5.0
>>> complex_abs(-5.5j)
5.5
"""
return
abs
(
a
)
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