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
6405dd9e
Commit
6405dd9e
authored
Jan 04, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
special case and optimise both PyInt and PyLong types in __Pyx_PyIndex_AsSsize_t()
parent
9e0417c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+20
-1
No files found.
Cython/Utility/TypeConversion.c
View file @
6405dd9e
...
...
@@ -276,11 +276,30 @@ 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
;
#if PY_MAJOR_VERSION < 3
if
(
likely
(
PyInt_CheckExact
(
b
)))
return
PyInt_AsSsize_t
(
b
);
return
PyInt_AS_LONG
(
b
);
#endif
if
(
likely
(
PyLong_CheckExact
(
b
)))
{
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
switch
(
Py_SIZE
(
b
))
{
case
-
1
:
return
-
(
sdigit
)((
PyLongObject
*
)
b
)
->
ob_digit
[
0
];
case
0
:
return
0
;
case
1
:
return
((
PyLongObject
*
)
b
)
->
ob_digit
[
0
];
}
#endif
#endif
return
PyLong_AsSsize_t
(
b
);
}
x
=
PyNumber_Index
(
b
);
if
(
!
x
)
return
-
1
;
ival
=
PyInt_AsSsize_t
(
x
);
...
...
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