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
f9d11146
Commit
f9d11146
authored
Jan 13, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce code overhead a little using a macro to get the sequence length of builtins.
parent
41e7e456
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-5
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+7
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
f9d11146
...
...
@@ -7472,17 +7472,14 @@ class SequenceNode(ExprNode):
code
.
putln
(
"PyObject* sequence = %s;"
%
rhs
.
py_result
())
# list/tuple => check size
code
.
putln
(
"#if !CYTHON_COMPILING_IN_PYPY"
)
code
.
putln
(
"Py_ssize_t size = Py_SIZE(sequence);"
)
code
.
putln
(
"#else"
)
code
.
putln
(
"Py_ssize_t size = PySequence_Size(sequence);"
)
# < 0 => exception
code
.
putln
(
"#endif"
)
code
.
putln
(
"Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);"
)
code
.
putln
(
"if (unlikely(size != %d)) {"
%
len
(
self
.
args
))
code
.
globalstate
.
use_utility_code
(
raise_too_many_values_to_unpack
)
code
.
putln
(
"if (size > %d) __Pyx_RaiseTooManyValuesError(%d);"
%
(
len
(
self
.
args
),
len
(
self
.
args
)))
code
.
globalstate
.
use_utility_code
(
raise_need_more_values_to_unpack
)
code
.
putln
(
"else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);"
)
# < 0 => exception
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
...
...
Cython/Utility/ModuleSetupCode.c
View file @
f9d11146
...
...
@@ -572,6 +572,13 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
#else
// NOTE: might fail with exception => check for -1
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_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