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
eea27293
Commit
eea27293
authored
Mar 23, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
speed up character switching in f-string parser a little
parent
9020149c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
Cython/Compiler/Parsing.pxd
Cython/Compiler/Parsing.pxd
+1
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+10
-8
No files found.
Cython/Compiler/Parsing.pxd
View file @
eea27293
...
...
@@ -70,7 +70,7 @@ cdef bint check_for_non_ascii_characters(unicode string)
cdef
p_string_literal
(
PyrexScanner
s
,
kind_override
=*
)
@
cython
.
locals
(
i
=
Py_ssize_t
,
size
=
Py_ssize_t
)
cdef
list
p_f_string
(
PyrexScanner
s
,
unicode_value
,
pos
)
@
cython
.
locals
(
i
=
Py_ssize_t
,
size
=
Py_ssize_t
)
@
cython
.
locals
(
i
=
Py_ssize_t
,
size
=
Py_ssize_t
,
c
=
Py_UCS4
,
quote_char
=
Py_UCS4
)
cdef
tuple
p_f_string_expr
(
PyrexScanner
s
,
unicode_value
,
pos
,
Py_ssize_t
starting_index
)
cdef
p_list_maker
(
PyrexScanner
s
)
cdef
p_comp_iter
(
PyrexScanner
s
,
body
)
...
...
Cython/Compiler/Parsing.py
View file @
eea27293
...
...
@@ -1032,9 +1032,10 @@ def p_f_string_expr(s, unicode_value, pos, starting_index):
size
=
len
(
unicode_value
)
conversion_char
=
terminal_char
=
format_spec
=
None
format_spec_str
=
u''
NO_CHAR
=
2
**
30
nested_depth
=
0
quote_char
=
N
one
quote_char
=
N
O_CHAR
in_triple_quotes
=
False
while
True
:
...
...
@@ -1042,17 +1043,17 @@ def p_f_string_expr(s, unicode_value, pos, starting_index):
s
.
error
(
"missing '}' in format string expression"
)
c
=
unicode_value
[
i
]
if
quote_char
is
not
None
:
if
quote_char
!=
NO_CHAR
:
if
c
==
'
\
\
'
:
i
+=
1
elif
c
==
quote_char
:
if
in_triple_quotes
:
if
i
+
2
<
size
and
unicode_value
[
i
+
1
]
==
c
and
unicode_value
[
i
+
2
]
==
c
:
in_triple_quotes
=
False
quote_char
=
N
one
quote_char
=
N
O_CHAR
i
+=
2
else
:
quote_char
=
N
one
quote_char
=
N
O_CHAR
elif
c
in
'
\
'
"'
:
quote_char
=
c
if
i
+
2
<
size
and
unicode_value
[
i
+
1
]
==
c
and
unicode_value
[
i
+
2
]
==
c
:
...
...
@@ -1103,11 +1104,12 @@ def p_f_string_expr(s, unicode_value, pos, starting_index):
if
nested_depth
>=
1
:
s
.
error
(
"nesting of '{' in format specifier is not allowed"
)
nested_depth
+=
1
elif
c
==
'}'
and
nested_depth
==
0
:
terminal_char
=
c
break
elif
c
==
'}'
:
if
nested_depth
>
0
:
nested_depth
-=
1
else
:
terminal_char
=
c
break
if
c
in
'
\
'
"'
:
if
not
in_string
and
i
+
2
<
size
and
unicode_value
[
i
+
1
]
==
c
and
unicode_value
[
i
+
2
]
==
c
:
in_triple_quotes
=
not
in_triple_quotes
...
...
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