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
e0a0d6af
Commit
e0a0d6af
authored
Mar 27, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise string concatenation for 2-item f-strings
parent
3937bfcc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+17
-7
No files found.
Cython/Compiler/ExprNodes.py
View file @
e0a0d6af
...
@@ -3023,6 +3023,10 @@ class FormattedValueNode(ExprNode):
...
@@ -3023,6 +3023,10 @@ class FormattedValueNode(ExprNode):
'a'
:
'PyObject_ASCII'
,
# NOTE: Py3-only!
'a'
:
'PyObject_ASCII'
,
# NOTE: Py3-only!
}.
get
}.
get
def
may_be_none
(
self
):
# PyObject_Format() always returns a string (str in Py3, str/unicode in Py2) or raises an exception
return
False
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
self
.
value
=
self
.
value
.
analyse_types
(
env
).
coerce_to_pyobject
(
env
)
self
.
value
=
self
.
value
.
analyse_types
(
env
).
coerce_to_pyobject
(
env
)
if
self
.
format_spec
:
if
self
.
format_spec
:
...
@@ -10592,9 +10596,15 @@ class AddNode(NumBinopNode):
...
@@ -10592,9 +10596,15 @@ class AddNode(NumBinopNode):
self
,
type1
,
type2
)
self
,
type1
,
type2
)
def
py_operation_function
(
self
,
code
):
def
py_operation_function
(
self
,
code
):
is_unicode_concat
=
False
if
isinstance
(
self
.
operand1
,
FormattedValueNode
)
or
isinstance
(
self
.
operand2
,
FormattedValueNode
):
is_unicode_concat
=
True
else
:
type1
,
type2
=
self
.
operand1
.
type
,
self
.
operand2
.
type
type1
,
type2
=
self
.
operand1
.
type
,
self
.
operand2
.
type
if
type1
is
unicode_type
or
type2
is
unicode_type
:
if
type1
is
unicode_type
or
type2
is
unicode_type
:
if
type1
.
is_builtin_type
and
type2
.
is_builtin_type
:
is_unicode_concat
=
type1
.
is_builtin_type
and
type2
.
is_builtin_type
if
is_unicode_concat
:
if
self
.
operand1
.
may_be_none
()
or
self
.
operand2
.
may_be_none
():
if
self
.
operand1
.
may_be_none
()
or
self
.
operand2
.
may_be_none
():
return
'__Pyx_PyUnicode_ConcatSafe'
return
'__Pyx_PyUnicode_ConcatSafe'
else
:
else
:
...
...
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