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
e9555bb4
Commit
e9555bb4
authored
May 16, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak 2**N optimisation a bit more in Py3
parent
43d26ad8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+11
-0
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+11
-10
No files found.
Cython/Utility/Optimize.c
View file @
e9555bb4
...
...
@@ -435,6 +435,7 @@ bad:
static
PyObject
*
__Pyx__PyNumber_PowerOf2
(
PyObject
*
two
,
PyObject
*
exp
,
PyObject
*
none
,
int
inplace
);
/*proto*/
/////////////// PyNumberPow2 ///////////////
//@requires: TypeConversion.c::PyLongInternals
static
PyObject
*
__Pyx__PyNumber_PowerOf2
(
PyObject
*
two
,
PyObject
*
exp
,
PyObject
*
none
,
int
inplace
)
{
// in CPython, 1<<N is substantially faster than 2**N
...
...
@@ -442,7 +443,17 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t
shiftby
;
if
(
likely
(
PyLong_CheckExact
(
exp
)))
{
#if PY_MAJOR_VERSION >= 3 && CYTHON_USE_PYLONG_INTERNALS
switch
(
Py_SIZE
(
exp
))
{
case
0
:
shiftby
=
0
;
break
;
case
1
:
shiftby
=
((
PyLongObject
*
)
exp
)
->
ob_digit
[
0
];
break
;
default:
if
(
unlikely
(
Py_SIZE
(
exp
)
<
0
))
goto
fallback
;
shiftby
=
PyLong_AsSsize_t
(
exp
);
break
;
}
#else
shiftby
=
PyLong_AsSsize_t
(
exp
);
#endif
#if PY_MAJOR_VERSION < 3
}
else
if
(
likely
(
PyInt_CheckExact
(
exp
)))
{
shiftby
=
PyInt_AsLong
(
exp
);
...
...
Cython/Utility/TypeConversion.c
View file @
e9555bb4
...
...
@@ -150,6 +150,7 @@ bad:
#endif
/////////////// TypeConversions ///////////////
//@requires: PyLongInternals
/* Type Conversion Functions */
...
...
@@ -279,11 +280,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
return
res
;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static
CYTHON_INLINE
Py_ssize_t
__Pyx_PyIndex_AsSsize_t
(
PyObject
*
b
)
{
Py_ssize_t
ival
;
PyObject
*
x
;
...
...
@@ -504,18 +500,23 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value) {
}
/////////////// PyLongInternals ///////////////
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
/////////////// CIntFromPy.proto ///////////////
static
CYTHON_INLINE
{{
TYPE
}}
{{
FROM_PY_FUNCTION
}}(
PyObject
*
);
/////////////// CIntFromPy ///////////////
//@requires: CIntFromPyVerify
//@requires: PyLongInternals
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static
CYTHON_INLINE
{{
TYPE
}}
{{
FROM_PY_FUNCTION
}}(
PyObject
*
x
)
{
const
{{
TYPE
}}
neg_one
=
({{
TYPE
}})
-
1
,
const_zero
=
0
;
const
int
is_unsigned
=
neg_one
>
const_zero
;
...
...
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