Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
20e1199f
Commit
20e1199f
authored
Mar 02, 2007
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix embarrassing typo and fix constantification of None
parent
117a05ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
Lib/test/test_peepholer.py
Lib/test/test_peepholer.py
+5
-0
Python/peephole.c
Python/peephole.c
+10
-6
No files found.
Lib/test/test_peepholer.py
View file @
20e1199f
...
...
@@ -49,6 +49,11 @@ class TestTranforms(unittest.TestCase):
self
.
assert_
(
elem
not
in
asm
)
for
elem
in
(
'LOAD_CONST'
,
'(None)'
):
self
.
assert_
(
elem
in
asm
)
def
f
():
'Adding a docstring made this test fail in Py2.5.0'
return
None
self
.
assert_
(
'LOAD_CONST'
in
disassemble
(
f
))
self
.
assert_
(
'LOAD_GLOBAL'
not
in
disassemble
(
f
))
def
test_while_one
(
self
):
# Skip over: LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP
...
...
Python/peephole.c
View file @
20e1199f
/* Peehole optimizations for bytecode compiler. */
/* Pee
p
hole optimizations for bytecode compiler. */
#include "Python.h"
...
...
@@ -386,13 +386,17 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
if
(
name
==
NULL
||
strcmp
(
name
,
"None"
)
!=
0
)
continue
;
for
(
j
=
0
;
j
<
PyList_GET_SIZE
(
consts
)
;
j
++
)
{
if
(
PyList_GET_ITEM
(
consts
,
j
)
==
Py_None
)
{
codestr
[
i
]
=
LOAD_CONST
;
SETARG
(
codestr
,
i
,
j
);
cumlc
=
lastlc
+
1
;
if
(
PyList_GET_ITEM
(
consts
,
j
)
==
Py_None
)
break
;
}
}
if
(
j
==
PyList_GET_SIZE
(
consts
))
{
if
(
PyList_Append
(
consts
,
Py_None
)
==
-
1
)
goto
exitUnchanged
;
}
assert
(
PyList_GET_ITEM
(
consts
,
j
)
==
Py_None
);
codestr
[
i
]
=
LOAD_CONST
;
SETARG
(
codestr
,
i
,
j
);
cumlc
=
lastlc
+
1
;
break
;
/* Skip over LOAD_CONST trueconst
...
...
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