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
9f1600bc
Commit
9f1600bc
authored
Mar 09, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce default decoding overhead in Py3
parent
a5403b1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-2
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+10
-8
No files found.
Cython/Compiler/ModuleNode.py
View file @
9f1600bc
...
...
@@ -562,8 +562,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
c_string_type
!=
'bytes'
and
not
c_string_encoding
:
error
(
self
.
pos
,
"a default encoding must be provided if c_string_type != bytes"
)
code
.
putln
(
'#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII %s'
%
int
(
c_string_encoding
==
'ascii'
))
code
.
putln
(
'#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT %s'
%
int
(
c_string_encoding
==
'default'
))
code
.
putln
(
'#define __PYX_DEFAULT_STRING_ENCODING "%s"'
%
c_string_encoding
)
if
c_string_encoding
==
'default'
:
code
.
putln
(
'#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 1'
)
else
:
code
.
putln
(
'#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0'
)
code
.
putln
(
'#define __PYX_DEFAULT_STRING_ENCODING "%s"'
%
c_string_encoding
)
code
.
putln
(
'#define __Pyx_PyObject_FromString __Pyx_Py%s_FromString'
%
c_string_type
.
title
())
code
.
putln
(
'#define __Pyx_PyObject_FromStringAndSize __Pyx_Py%s_FromStringAndSize'
%
c_string_type
.
title
())
code
.
put
(
UtilityCode
.
load_as_string
(
"TypeConversions"
,
"TypeConversion.c"
)[
0
])
...
...
Cython/Utility/TypeConversion.c
View file @
9f1600bc
...
...
@@ -8,7 +8,6 @@ static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t*
#define __Pyx_PyBytes_FromString PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static
CYTHON_INLINE
PyObject
*
__Pyx_PyUnicode_FromString
(
char
*
);
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
...
...
@@ -101,10 +100,16 @@ bad:
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
// __PYX_DEFAULT_STRING_ENCODING is either a user provided string constant
// or we need to look it up here
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#undef __PYX_DEFAULT_STRING_ENCODING
#if PY_MAJOR_VERSION < 3
static
char
*
__PYX_DEFAULT_STRING_ENCODING
;
static
int
__Pyx_init_sys_getdefaultencoding_params
()
{
PyObject
*
sys
=
NULL
;
PyObject
*
default_encoding
=
NULL
;
...
...
@@ -116,20 +121,17 @@ static int __Pyx_init_sys_getdefaultencoding_params() {
default_encoding_c
=
PyBytes_AS_STRING
(
default_encoding
);
__PYX_DEFAULT_STRING_ENCODING
=
(
char
*
)
malloc
(
strlen
(
default_encoding_c
));
strcpy
(
__PYX_DEFAULT_STRING_ENCODING
,
default_encoding_c
);
Py_
X
DECREF
(
sys
);
Py_
X
DECREF
(
default_encoding
);
Py_DECREF
(
sys
);
Py_DECREF
(
default_encoding
);
return
0
;
bad:
Py_XDECREF
(
sys
);
Py_XDECREF
(
default_encoding
);
return
-
1
;
}
#else
#define __PYX_DEFAULT_STRING_ENCODING "utf-8"
#endif
#endif
/////////////// TypeConversions ///////////////
/* Type Conversion Functions */
...
...
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