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
Kirill Smelkov
cython
Commits
813b5a9e
Commit
813b5a9e
authored
Aug 18, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise abs(double) and abs(int)
parent
ae00ae99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+11
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-0
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+4
-0
No files found.
Cython/Compiler/Builtin.py
View file @
813b5a9e
...
...
@@ -283,10 +283,12 @@ builtin_utility_code = {
class
_BuiltinOverride
(
object
):
def
__init__
(
self
,
py_name
,
args
,
ret_type
,
cname
,
py_equiv
=
"*"
,
utility_code
=
None
,
sig
=
None
,
func_type
=
None
):
utility_code
=
None
,
sig
=
None
,
func_type
=
None
,
is_strict_signature
=
False
):
self
.
py_name
,
self
.
cname
,
self
.
py_equiv
=
py_name
,
cname
,
py_equiv
self
.
args
,
self
.
ret_type
=
args
,
ret_type
self
.
func_type
,
self
.
sig
=
func_type
,
sig
self
.
is_strict_signature
=
is_strict_signature
self
.
utility_code
=
utility_code
class
BuiltinAttribute
(
object
):
...
...
@@ -312,6 +314,8 @@ class BuiltinFunction(_BuiltinOverride):
if
sig
is
None
:
sig
=
Signature
(
self
.
args
,
self
.
ret_type
)
func_type
=
sig
.
function_type
()
if
self
.
is_strict_signature
:
func_type
.
is_strict_signature
=
True
scope
.
declare_builtin_cfunction
(
self
.
py_name
,
func_type
,
self
.
cname
,
self
.
py_equiv
,
self
.
utility_code
)
...
...
@@ -332,6 +336,12 @@ class BuiltinMethod(_BuiltinOverride):
builtin_function_table
=
[
# name, args, return, C API func, py equiv = "*"
BuiltinFunction
(
'abs'
,
"d"
,
"d"
,
"fabs"
,
is_strict_signature
=
True
),
BuiltinFunction
(
'abs'
,
"f"
,
"f"
,
"fabsf"
,
is_strict_signature
=
True
),
BuiltinFunction
(
'abs'
,
"i"
,
"l"
,
"labs"
,
is_strict_signature
=
True
),
BuiltinFunction
(
'abs'
,
"O"
,
"O"
,
"PyNumber_Absolute"
),
#('chr', "", "", ""),
#('cmp', "", "", "", ""), # int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
...
...
Cython/Compiler/PyrexTypes.py
View file @
813b5a9e
...
...
@@ -1697,9 +1697,12 @@ class CFuncType(CType):
# nogil boolean Can be called without gil
# with_gil boolean Acquire gil around function body
# templates [string] or None
# is_strict_signature boolean function refuses to accept coerced arguments
# (used for optimisation overrides)
is_cfunction
=
1
original_sig
=
None
is_strict_signature
=
False
def
__init__
(
self
,
return_type
,
args
,
has_varargs
=
0
,
exception_value
=
None
,
exception_check
=
0
,
calling_convention
=
""
,
...
...
@@ -2592,6 +2595,8 @@ def best_match(args, functions, pos=None):
if
dst_type
.
assignable_from
(
src_type
):
if
src_type
==
dst_type
or
dst_type
.
same_as
(
src_type
):
pass
# score 0
elif
func_type
.
is_strict_signature
:
break
# exact match requested but not found
elif
is_promotion
(
src_type
,
dst_type
):
score
[
2
]
+=
1
elif
not
src_type
.
is_pyobject
:
...
...
Cython/Compiler/TypeSlots.py
View file @
813b5a9e
...
...
@@ -32,6 +32,8 @@ class Signature(object):
# 'b' bint
# 'I' int *
# 'l' long
# 'f' float
# 'd' double
# 'h' Py_hash_t
# 'z' Py_ssize_t
# 'Z' Py_ssize_t *
...
...
@@ -53,6 +55,8 @@ class Signature(object):
'b'
:
PyrexTypes
.
c_bint_type
,
'I'
:
PyrexTypes
.
c_int_ptr_type
,
'l'
:
PyrexTypes
.
c_long_type
,
'f'
:
PyrexTypes
.
c_float_type
,
'd'
:
PyrexTypes
.
c_double_type
,
'h'
:
PyrexTypes
.
c_py_hash_t_type
,
'z'
:
PyrexTypes
.
c_py_ssize_t_type
,
'Z'
:
PyrexTypes
.
c_py_ssize_t_ptr_type
,
...
...
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