Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
76d962d7
Kaydet (Commit)
76d962d7
authored
Tem 16, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Treat None as a constant.
üst
11d9b062
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
NEWS
Misc/NEWS
+2
-0
compile.c
Python/compile.c
+20
-4
No files found.
Misc/NEWS
Dosyayı görüntüle @
76d962d7
...
...
@@ -26,6 +26,8 @@ Core and builtins
-
Added
C
macros
Py_CLEAR
and
Py_VISIT
to
ease
the
implementation
of
types
that
support
garbage
collection
.
-
Compiler
now
treats
None
as
a
constant
.
Extension
modules
-----------------
...
...
Python/compile.c
Dosyayı görüntüle @
76d962d7
...
...
@@ -363,12 +363,13 @@ markblocks(unsigned char *code, int len)
}
static
PyObject
*
optimize_code
(
PyObject
*
code
,
PyObject
*
consts
)
optimize_code
(
PyObject
*
code
,
PyObject
*
consts
,
PyObject
*
names
)
{
int
i
,
j
,
codelen
;
int
tgt
,
tgttgt
,
opcode
;
unsigned
char
*
codestr
;
unsigned
int
*
blocks
;
char
*
name
;
/* Make a modifiable copy of the code string */
if
(
!
PyString_Check
(
code
))
...
...
@@ -418,6 +419,21 @@ optimize_code(PyObject *code, PyObject* consts)
continue
;
SETARG
(
codestr
,
i
,
(
j
^
1
));
codestr
[
i
+
3
]
=
NOP
;
/* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */
case
LOAD_NAME
:
case
LOAD_GLOBAL
:
j
=
GETARG
(
codestr
,
i
);
name
=
PyString_AsString
(
PyTuple_GET_ITEM
(
names
,
j
));
if
(
name
==
NULL
||
strcmp
(
name
,
"None"
)
!=
0
)
continue
;
for
(
j
=
0
;
j
<
PyTuple_GET_SIZE
(
consts
)
;
j
++
)
{
if
(
PyTuple_GET_ITEM
(
consts
,
j
)
==
Py_None
)
{
codestr
[
i
]
=
LOAD_CONST
;
SETARG
(
codestr
,
i
,
j
);
break
;
}
}
break
;
/* Skip over LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP.
...
...
@@ -441,7 +457,7 @@ optimize_code(PyObject *code, PyObject* consts)
continue
;
if
(
!
ISBASICBLOCK
(
blocks
,
i
,
6
))
continue
;
if
(
GETARG
(
codestr
,
i
)
==
2
&&
\
if
(
GETARG
(
codestr
,
i
)
==
2
&&
GETARG
(
codestr
,
i
+
3
)
==
2
)
{
codestr
[
i
]
=
ROT_TWO
;
codestr
[
i
+
1
]
=
JUMP_FORWARD
;
...
...
@@ -450,7 +466,7 @@ optimize_code(PyObject *code, PyObject* consts)
codestr
[
i
+
5
]
=
NOP
;
continue
;
}
if
(
GETARG
(
codestr
,
i
)
==
3
&&
\
if
(
GETARG
(
codestr
,
i
)
==
3
&&
GETARG
(
codestr
,
i
+
3
)
==
3
)
{
codestr
[
i
]
=
ROT_THREE
;
codestr
[
i
+
1
]
=
ROT_TWO
;
...
...
@@ -542,7 +558,7 @@ PyCode_New(int argcount, int nlocals, int stacksize, int flags,
co
->
co_nlocals
=
nlocals
;
co
->
co_stacksize
=
stacksize
;
co
->
co_flags
=
flags
;
co
->
co_code
=
optimize_code
(
code
,
consts
);
co
->
co_code
=
optimize_code
(
code
,
consts
,
names
);
Py_INCREF
(
consts
);
co
->
co_consts
=
consts
;
Py_INCREF
(
names
);
...
...
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