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
b615bf06
Kaydet (Commit)
b615bf06
authored
Şub 10, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove the set conversion which didn't work with: [] in (0,)
üst
4e9907c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
53 deletions
+1
-53
compile.c
Python/compile.c
+1
-53
No files found.
Python/compile.c
Dosyayı görüntüle @
b615bf06
...
...
@@ -542,53 +542,6 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
return
1
;
}
/* Replace LOAD_CONST tuple with LOAD_CONST frozenset in the context
of a single-use constant for "in" and "not in" tests.
*/
int
try_set_conversion
(
unsigned
char
*
codestr
,
PyObject
*
consts
)
{
PyObject
*
newconst
,
*
constant
;
int
arg
,
len_consts
;
/* Pre-conditions */
assert
(
PyList_CheckExact
(
consts
));
assert
(
codestr
[
0
]
==
LOAD_CONST
);
assert
(
codestr
[
3
]
==
COMPARE_OP
);
assert
(
GETARG
(
codestr
,
3
)
==
6
||
GETARG
(
codestr
,
3
)
==
7
);
/* Attempt to convert constant to a frozenset. Bail-out with no
changes if the tuple contains unhashable values. */
arg
=
GETARG
(
codestr
,
0
);
constant
=
PyList_GET_ITEM
(
consts
,
arg
);
if
(
constant
->
ob_type
!=
&
PyTuple_Type
)
return
0
;
newconst
=
PyObject_CallFunctionObjArgs
(
(
PyObject
*
)
&
PyFrozenSet_Type
,
constant
,
NULL
);
if
(
newconst
==
NULL
)
{
PyErr_Clear
();
return
0
;
}
/* Append new constant onto consts list or replace existing constant
if there are no other references to it.*/
if
(
constant
->
ob_refcnt
==
1
)
{
PyList_SET_ITEM
(
consts
,
arg
,
newconst
);
Py_DECREF
(
constant
);
return
1
;
}
len_consts
=
PyList_GET_SIZE
(
consts
);
if
(
PyList_Append
(
consts
,
newconst
))
{
Py_DECREF
(
newconst
);
return
0
;
}
Py_DECREF
(
newconst
);
/* Write new LOAD_CONST newconst on top of LOAD_CONST oldconst */
SETARG
(
codestr
,
0
,
len_consts
);
return
1
;
}
static
unsigned
int
*
markblocks
(
unsigned
char
*
code
,
int
len
)
{
...
...
@@ -714,15 +667,10 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
/* not a is b --> a is not b
not a in b --> a not in b
not a is not b --> a is b
not a not in b --> a in b
a in c --> a in frozenset(c)
where c is a constant tuple of hashable values
not a not in b --> a in b
*/
case
COMPARE_OP
:
j
=
GETARG
(
codestr
,
i
);
if
(
lastlc
>=
1
&&
(
j
==
6
||
j
==
7
)
&&
ISBASICBLOCK
(
blocks
,
i
-
3
,
6
))
try_set_conversion
(
&
codestr
[
i
-
3
],
consts
);
if
(
j
<
6
||
j
>
9
||
codestr
[
i
+
3
]
!=
UNARY_NOT
||
!
ISBASICBLOCK
(
blocks
,
i
,
4
))
...
...
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