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
c132ad9c
Commit
c132ad9c
authored
Sep 14, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid dict resizing while creating fixed-size dicts.
parent
3fdd71a9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
5 deletions
+13
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-1
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+1
-1
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+6
-0
Cython/Utility/Printing.c
Cython/Utility/Printing.c
+2
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
c132ad9c
...
@@ -8471,8 +8471,9 @@ class DictNode(ExprNode):
...
@@ -8471,8 +8471,9 @@ class DictNode(ExprNode):
if
is_dict
:
if
is_dict
:
self
.
release_errors
()
self
.
release_errors
()
code
.
putln
(
code
.
putln
(
"%s =
PyDict_New(
); %s"
%
(
"%s =
__Pyx_PyDict_NewPresized(%d
); %s"
%
(
self
.
result
(),
self
.
result
(),
len
(
self
.
key_value_pairs
),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
code
.
put_gotref
(
self
.
py_result
())
...
...
Cython/Compiler/PyrexTypes.py
View file @
c132ad9c
...
@@ -3167,7 +3167,8 @@ class ToPyStructUtilityCode(object):
...
@@ -3167,7 +3167,8 @@ class ToPyStructUtilityCode(object):
code
.
putln
(
"%s {"
%
self
.
header
)
code
.
putln
(
"%s {"
%
self
.
header
)
code
.
putln
(
"PyObject* res;"
)
code
.
putln
(
"PyObject* res;"
)
code
.
putln
(
"PyObject* member;"
)
code
.
putln
(
"PyObject* member;"
)
code
.
putln
(
"res = PyDict_New(); if (unlikely(!res)) return NULL;"
)
code
.
putln
(
"res = __Pyx_PyDict_NewPresized(%d); if (unlikely(!res)) return NULL;"
%
len
(
self
.
type
.
scope
.
var_entries
))
for
member
in
self
.
type
.
scope
.
var_entries
:
for
member
in
self
.
type
.
scope
.
var_entries
:
nameconst_cname
=
code
.
get_py_string_const
(
member
.
name
,
identifier
=
True
)
nameconst_cname
=
code
.
get_py_string_const
(
member
.
name
,
identifier
=
True
)
code
.
putln
(
"%s; if (unlikely(!member)) goto bad;"
%
(
code
.
putln
(
"%s; if (unlikely(!member)) goto bad;"
%
(
...
...
Cython/Utility/Coroutine.c
View file @
c132ad9c
...
@@ -1742,7 +1742,7 @@ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_c
...
@@ -1742,7 +1742,7 @@ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_c
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
int
result
;
int
result
;
PyObject
*
globals
,
*
result_obj
;
PyObject
*
globals
,
*
result_obj
;
globals
=
PyDict_New
(
);
if
(
unlikely
(
!
globals
))
goto
ignore
;
globals
=
__Pyx_PyDict_NewPresized
(
4
);
if
(
unlikely
(
!
globals
))
goto
ignore
;
result
=
PyDict_SetItemString
(
globals
,
"_cython_coroutine_type"
,
result
=
PyDict_SetItemString
(
globals
,
"_cython_coroutine_type"
,
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Coroutine_USED
(
PyObject
*
)
__pyx_CoroutineType
);
(
PyObject
*
)
__pyx_CoroutineType
);
...
...
Cython/Utility/ModuleSetupCode.c
View file @
c132ad9c
...
@@ -255,6 +255,12 @@
...
@@ -255,6 +255,12 @@
#define __Pyx_PyThreadState_Current _PyThreadState_Current
#define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n) _PyDict_NewPresized(n)
#else
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
...
...
Cython/Utility/Printing.c
View file @
c132ad9c
...
@@ -83,7 +83,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
...
@@ -83,7 +83,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
return
-
1
;
return
-
1
;
}
}
if
(
stream
)
{
if
(
stream
)
{
kwargs
=
PyDict_New
(
);
kwargs
=
__Pyx_PyDict_NewPresized
(
2
);
if
(
unlikely
(
!
kwargs
))
if
(
unlikely
(
!
kwargs
))
return
-
1
;
return
-
1
;
if
(
unlikely
(
PyDict_SetItem
(
kwargs
,
PYIDENT
(
"file"
),
stream
)
<
0
))
if
(
unlikely
(
PyDict_SetItem
(
kwargs
,
PYIDENT
(
"file"
),
stream
)
<
0
))
...
@@ -100,7 +100,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
...
@@ -100,7 +100,7 @@ static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
}
}
}
else
if
(
!
newline
)
{
}
else
if
(
!
newline
)
{
if
(
unlikely
(
!
$
print_function_kwargs
))
{
if
(
unlikely
(
!
$
print_function_kwargs
))
{
$
print_function_kwargs
=
PyDict_New
(
);
$
print_function_kwargs
=
__Pyx_PyDict_NewPresized
(
1
);
if
(
unlikely
(
!
$
print_function_kwargs
))
if
(
unlikely
(
!
$
print_function_kwargs
))
return
-
1
;
return
-
1
;
end_string
=
PyUnicode_FromStringAndSize
(
" "
,
1
);
end_string
=
PyUnicode_FromStringAndSize
(
" "
,
1
);
...
...
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